到 Heroku 的 Nodejs 部署错误
Posted
技术标签:
【中文标题】到 Heroku 的 Nodejs 部署错误【英文标题】:Nodejs deployment error to Heroku 【发布时间】:2018-04-19 14:12:15 【问题描述】:我在将我的 Node 应用程序部署到 Heroku 时遇到问题,我指定了节点和 npm 版本,设置了 procfile,但又遇到了问题,谁能帮我解决我的错误。
这是错误日志。
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NPM_CONFIG_PRODUCTION=true
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): 6.7.0
engines.npm (package.json): 3.10.3
Resolving node version 6.7.0...
Downloading and installing node 6.7.0...
npm 3.10.3 already installed with node
-----> Restoring cache
Skipping cache restore (not-found)
-----> Building dependencies
Prebuild detected (node_modules already exists)
Rebuilding any native modules
> bcrypt@1.0.3 install /tmp/build_41d193481a84256234156f8c6f5f2420/goransgit-Random-Movie-ec7e060/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build
sh: 1: node-pre-gyp: Permission denied
npm ERR! Linux 3.13.0-133-generic
npm ERR! argv "/tmp/build_41d193481a84256234156f8c6f5f2420/goransgit-Random-Movie-ec7e060/.heroku/node/bin/node" "/tmp/build_41d193481a84256234156f8c6f5f2420/goransgit-Random-Movie-ec7e060/.heroku/node/bin/npm" "rebuild"
npm ERR! node v6.7.0
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! bcrypt@1.0.3 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the bcrypt@1.0.3 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bcrypt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs bcrypt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls bcrypt
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /tmp/build_41d193481a84256234156f8c6f5f2420/goransgit-Random-Movie-ec7e060/npm-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
Some possible problems:
- node_modules checked into source control
https://blog.heroku.com/node-habits-2016#9-only-git-the-important-bits
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
这是我的 package.json 文件,其中包含所有必要的依赖项。
"name": "Node app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts":
"start": "node index.js"
,
"author": "",
"license": "ISC",
"dependencies":
"bcrypt": "^1.0.3",
"body-parser": "^1.18.2",
"cookie-parser": "^1.4.3",
"express-session": "^1.15.6",
"express-validator": "^4.2.1",
"form-validate": "0.0.7",
"passport": "^0.4.0",
"validator": "^9.1.1"
,
"engines" :
"node" : "6.7.0",
"npm" : "3.10.3"
如果有人可以帮助我,谢谢。
不要介意下面的 LOREM IPSUM Nostrud reprehenderit sed amet enim nulla pariatur ut dolore officia duis fugiat elite excepteur in nostrud duis irure in ut cillum sunt sunt ut incididunt in culpa in veniam adipisicing aliquip exercitation enim dolore exercitation mollit eu sunt irure excepteur magna mollit esse non dolor fugiast consequat ex adipisicing culpa aliquip eu in dolor do excepteur quis aliquip enim eu ut dolor ex culpa ullamco deserunt in et deserunt in occaecat ex do dolor do dolore veniam est elit elit elit minim cupidatat mollit nisi sint non adipisicing cillum ullamco reprehenderit do nisi nulla commodont in eu tempor incididunt sunt cupidatat velit dolor culpa sat est elit veniam dolor irure in irure minim dolor sit nisi est pariatur officia esse aliquip ex enim sint cupidatat eu excepteur laborum mollit ut ullamco cillum cillum veniam qui laboris excepteur ex sed commodo magna adipisicing do culpa paria reprehenderit eu deserunt quis adipisicing nisi sunt ad ad dolore 事件 dolor sint sint et labourum ea magna ea incididunt non esse non sunt sint est ad veniam ullamco ad dolor sint ut aliqua incididunt ullamco non nulla proident reprehenderit anim esse non dolor sint pariatur aliqua exceptioneur irure non aute sed ut veniam labouris ad occaecat adipiic labouris occaecat labourum laboris culpa in Incidudunt labore in sed tempor dolore in quis reprehenderit enim mollit dolor esse。
【问题讨论】:
【参考方案1】:一些可能的问题: - node_modules 签入源代码管理
将 node_modules 放在你的 .gitignore 文件中。此目录不应位于 git 存储库中。
然后从git中删除目录:
git rm -r node_modules
git commit -m "Remove node_modules directory"
然后推送到 Heroku
我建议在 Node.js 项目中使用这个 gitignore 文件: https://github.com/github/gitignore/blob/master/Node.gitignore
【讨论】:
请在 cmets 中提出这些问题。答案应该是完整的解决方案。 “你必须有50声望才能评论”,所以我不能在cmets中提问。以上是关于到 Heroku 的 Nodejs 部署错误的主要内容,如果未能解决你的问题,请参考以下文章
Angular 2/Nodejs 部署到 heroku 错误 heroku-postbuild: `ng build`