我在向Heroku部署NodeJS应用时遇到问题。 这是错误:
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): 5.3.0
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 5.3.0...
remote: Downloading and installing node 5.3.0...
remote: Detected package-lock.json: defaulting npm to version 5.x.x
remote: Bootstrapping npm 5.x.x (replacing 3.3.12)...
remote: npm 5.5.1 installed
remote:
remote: -----> Restoring cache
remote: Skipping cache restore (not-found)
remote:
remote: -----> Building dependencies
remote: Installing node modules (package.json + package-lock)
remote: npm ERR! Buffer.alloc is not a function
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /app/.npm/_logs/2017-10-21T22_24_56_159Z-debug.log
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: If you're stuck, please submit a ticket so we can help:
remote: https://help.heroku.com/
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 young-ridge-96999.
remote:
To https://git.heroku.com/young-ridge-96999.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/young-ridge-96999.git
我已尝试过其他Stack Overflow问题的建议:
该应用的.gitignore
有node_modules/
package.json有
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
我试过建立一个新的分支并用新分支推送到Heroku
和
git add .
git commit -a -m'comment'
git push
由于
答案 0 :(得分:0)
这很可能是由于您使用旧版本的Node。您可以使用nvm安装最新版本。在package.json中准确指定您在本地使用的npm版本(npm --version
)也可以提供帮助,但我建议升级到最新版本的Node。