2017-10-21 171 views
1

我遇到了将NodeJS应用程序部署到Heroku的问题。 这是错误:推送失败! [远程拒绝]主 - >主(预接收钩拒绝)

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 

我曾尝试在其他堆栈溢出问题的建议: 的.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 

感谢

+1

可能重复[TypeError:Buffer.alloc不是函数](https://stackoverflow.com/questions/36499840/typeerror-buffer-alloc-is-not-a-function) – max630

回答

0

这很可能是由于您使用的是旧版本的节点来。您可以使用nvm安装最新版本。在package.json中确切指定你在本地使用的npm版本(npm --version)也有帮助,但我建议升级到最新版本的Node。

相关问题