node.js - 部署heroku应用程序失败

标签 node.js git heroku

这是错误日志:

remote: Compressing source files... done.
remote: Building source:remote:
remote: -----> Node.js app detected
remote: 
remote: -----> Creating runtime environment
remote:        
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NPM_CONFIG_PRODUCTION=true
remote:        NODE_VERBOSE=false
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote: 
remote: -----> Installing binaries
remote:        engines.node (package.json):  ~6.11.0
remote:        engines.npm (package.json):   ~5.0.3
remote:        
remote:        Resolving node version ~6.11.0 via semver.io...
remote:        Downloading and installing node 6.11.1...
remote:        Resolving npm version ~5.0.3 via semver.io...
remote:        Downloading and installing npm 5.0.4 (replacing version 
3.10.10)...
remote: 
remote: -----> Restoring cache
remote:        Skipping cache restore (new-signature)
remote: 
remote: -----> Building dependencies
remote:        Prebuild detected (node_modules already exists)
remote:        Rebuilding any native modules
remote:        npm ERR! path 
/tmp/build_9c402097d0e7567eccf5e236dc7f0959/node_modules/jade/bin/jade.js
remote:        npm ERR! code ENOENT
remote:        npm ERR! errno -2
remote:        npm ERR! syscall chmod
remote:        npm ERR! enoent ENOENT: no such file or directory, chmod 
'/tmp/build_9c402097d0e7567eccf5e236dc7f0959/node_modules/jade/bin/jade.js'
remote:        npm ERR! enoent This is related to npm not being able to 
find a file.
remote:        npm ERR! enoent
remote:        
remote:        npm ERR! A complete log of this run can be found in:
remote:        npm ERR!     /app/.npm/_logs/2017-07-16T02_45_14_132Z-
debug.log
remote: 
remote: -----> Build failed
remote:        
remote:        We're sorry this build is failing! You can troubleshoot 
common issues here:
remote:        
remote:        Some possible problems:
remote:        
remote:        - node_modules checked into source control
remote:        
remote:        Love,
remote:        Heroku
remote:        
remote:  !     Push rejected, failed to compile Node.js app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to pacific-harbor-25184.
remote: 
To https://git.heroku.com/pacific-harbor-25184.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/pacific-harbor-25184.git'

部署到 Heroku 时如何解决此构建错误? (即使它在本地工作)

最佳答案

这类似于最近的 issue in cloudfoundry (但同样的想法也适用于 Heroku)

男性肯定,在您的本地项目中,首先忽略node_modules:

echo 'node_modules' >> .gitignore
git rm -r --cached node_modules
git commit -m "ignore node_modules"

然后再次尝试 Heroku 部署。

关于node.js - 部署heroku应用程序失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45124667/

相关文章:

javascript - 将快速 js 路由转发到其他服务器

git pull 导致冲突

git - 有没有一种干净的方法来处理两个以相同内容开头的原始 git 存储库?

ruby-on-rails-3 - 如何清空 Heroku 数据库

javascript - Heroku - 特定路线在本地有效,但不适用于生产

node.js - 我可以将 JQuery mobile 与 Nodejs 一起使用吗

node.js - 将 async/await 与 setTimeout 函数结合起来

node.js - 无法在 ubuntu 上使用 Nodemon

Git master 分支 merge 后根本没有新文件

ruby-on-rails - 正常运行时间机器人 : ping heroku app always down