尝试部署到Heroku时找不到文件(在本地工作) [英] Cannot find file on trying to deploy to heroku (works locally)

查看:94
本文介绍了尝试部署到Heroku时找不到文件(在本地工作)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的应用程序部署到Heroku,它可以在本地运行,但在线上没有运气.我删除并重新安装了节点模块.

I am trying to deploy my app to Heroku, it works in local but no luck online. I deleted and reinstalled node modules.

我还有另一个与此完全相关的错误(文件找不到相同的名称等),我改变了相对路径,以解决此问题,但没有任何结果

I had another error quite related to this (file not found same names etc) I changed the relative paths thinking that would fix the issue but I am getting nothing to come out of it

错误是:

找不到文件'./Components/SearchBar/SearchBar'

Cannot find file './Components/SearchBar/SearchBar'

import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import SearchBar from './Components/SearchBar/SearchBar'
import BusinessList from './Components/BusinessList/BusinessList'
import Business from './Components/Business/Business'
import Yelp from './Components/Util/Yelp'

我希望不会因为如此简单的操作而出错,我已经遍历了文件和文件夹的名称,但这没有任何意义.

I expected to not pull an error for something so simple, I've poured over the file and folder names and it just is not making sense.

PS,我认为它可能是未连接的,我的const yelpApiKey = process.env.yelpApiKey可以让我的heroku连接到我的API密钥(在我的帐户中键入)

PS I think it's probably unconnected I have const yelpApiKey=process.env.yelpApiKey for my heroku to connect to my API key (typed inside my account)

推荐答案

我发现您的代码有2个问题:

I found 2 problems with your code:

  1. 导入路径区分大小写(对于某些环境).而且您使用的是" C 组件"而不是" c 组件"
  2. 在index.js中导入"App"是错误的.使用以下内容

  1. Import path is case sensitive(for some environments). And you are using 'Components' instead of 'components'
  2. Import of 'App' in index.js is wrong. Use following

import App from './App';

这篇关于尝试部署到Heroku时找不到文件(在本地工作)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆