这是错误日志:

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/

10-13 07:18
查看更多