Heroku在部署时找不到我的文件,但可以在本地使用

时间:2020-06-17 17:57:07

标签: git heroku npm heroku-cli

当我尝试使用git push heroku master 部署到Heroku时,出现此错误:! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/afternoon-inlet-19669.git'

我找到了另一个StackOverflow question,它帮助我摆脱了第一个错误。显然,GitHub不会在提交时更新文件名的大小写更改。因此,我意识到我有一个名为spinner.js的文件,该文件实际上在本地计算机上名为Spinner.js。

但是现在,我又遇到了错误。

-----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       NODE_VERBOSE=false
       
-----> Installing binaries
       engines.node (package.json):  12.x
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 12.x...
       Downloading and installing node 12.18.0...
       Using default npm version: 6.14.4
       
-----> Installing dependencies
       Installing node modules (package.json + package-lock)
       
       > nodemon@2.0.4 postinstall /tmp/build_94cb6f8d6d9567ec2a8f7d9ac35a0f48/node_modules/nodemon
       > node bin/postinstall || exit 0
       
       Love nodemon? You can now support the project via the open collective:
        > https://opencollective.com/nodemon/donate
       
       added 370 packages from 220 contributors and audited 371 packages in 12.257s
       
       12 packages are looking for funding
         run `npm fund` for details
       
       found 1 low severity vulnerability
         run `npm audit fix` to fix them, or `npm audit` for details
       
-----> Build
       Running heroku-postbuild
       
       > devconnector@1.0.0 heroku-postbuild /tmp/build_94cb6f8d6d9567ec2a8f7d9ac35a0f48
       > NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client
       
       
       > core-js@2.6.11 postinstall /tmp/build_94cb6f8d6d9567ec2a8f7d9ac35a0f48/client/node_modules/babel-runtime/node_modules/core-js
       > node -e "try{require('./postinstall')}catch(e){}"
       
       
       > core-js@3.6.5 postinstall /tmp/build_94cb6f8d6d9567ec2a8f7d9ac35a0f48/client/node_modules/core-js
       > node -e "try{require('./postinstall')}catch(e){}"
       
       
       > core-js-pure@3.6.5 postinstall /tmp/build_94cb6f8d6d9567ec2a8f7d9ac35a0f48/client/node_modules/core-js-pure
       > node -e "try{require('./postinstall')}catch(e){}"
       
       added 1686 packages from 803 contributors and audited 1690 packages in 41.105s
       
       59 packages are looking for funding
         run `npm fund` for details
       
       found 1 low severity vulnerability
         run `npm audit fix` to fix them, or `npm audit` for details
       
       > client@0.1.0 build /tmp/build_94cb6f8d6d9567ec2a8f7d9ac35a0f48/client
       > react-scripts build
       
       Creating an optimized production build...
       Failed to compile.
       
       ./src/components/dashboard/Dashboard.js
       Cannot find file '../layout/Spinner' in './src/components/dashboard'.
       
       
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the client@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npmcache.BfgW5/_logs/2020-06-17T17_40_23_134Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! devconnector@1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the devconnector@1.0.0 heroku-postbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npmcache.BfgW5/_logs/2020-06-17T17_40_23_146Z-debug.log
-----> Build failed
       
       We're sorry this build is failing! You can troubleshoot common issues here:
       https://devcenter.heroku.com/articles/troubleshooting-node-deploys
       
       If you're stuck, please submit a ticket so we can help:
       https://help.heroku.com/
       
       Love,
       Heroku
       
 !     Push rejected, failed to compile Node.js app.
 !     Push failed

这是我在GitHub上的项目的链接,您知道为什么Heroku拒绝推送该应用程序吗? My Project Link

编辑

我相信解决方案是让Github意识到我的文件名已经更改,它仍然必须认为该文件名为spinner.js。

2 个答案:

答案 0 :(得分:1)

您应该清理Heroku缓存:

heroku repo:purge_cache -a your_app_name

然后重试。

答案 1 :(得分:0)

我遇到了同样的问题,我花了 100 个小时才弄明白。原来我在 .gitignore 中添加了一个强制文件名....

因此,一个文件既没有上传到 Github,也没有上传到 Heroku。 Heroku 不会告诉我缺少哪个文件,但是如果您尝试将应用程序上传到那里,DigitalOcean 会告诉您具体缺少哪个文件。 只需检查您的 .gitignore 文件,不要阻塞节点模块以外的任何内容。甚至不要阻止上传 package-lock.json 文件。

如果这不是问题,那么可能是区分大小写的问题,其中文件名或组件名称与导入名称相比,每个字母的大小写都不相同。不过可能是 .gitignore 的事情。

相关问题