在Heroku上安装bcrypt NPM依赖项时权限被拒绝

时间:2020-08-25 21:59:23

标签: node.js heroku bcrypt

我在将应用程序部署到Heorku时遇到问题,我在安装Heroku的同一个git存储库中有一个现有的应用程序(节点js服务器),当我推送Heroku master(git push heroku master)时,我收到了此消息输出:

我剪了一些代码。

C:\some_folders>git push heroku master
remote: -----> Installing binaries
remote:        engines.node (package.json):  unspecified
remote:        engines.npm (package.json):   unspecified (use default)
remote:
remote:        Resolving node version 12.x...
remote:        Downloading and installing node 12.18.3...
remote:        Using default npm version: 6.14.6
remote:
remote: -----> Installing dependencies
remote:        Prebuild detected (node_modules already exists)
remote:        Rebuilding any native modules
remote:
remote:        > bcrypt@5.0.0 install /tmp/build_1be9d777/node_modules/bcrypt
remote:        > node-pre-gyp install --fallback-to-build
remote:
remote:        sh: 1: node-pre-gyp: Permission denied
remote:        npm ERR! code ELIFECYCLE
remote:        npm ERR! errno 126
remote:        npm ERR! bcrypt@5.0.0 install: `node-pre-gyp install --fallback-to-build`
remote:        npm ERR! Exit status 126
remote:        npm ERR!
remote:        npm ERR! Failed at the bcrypt@5.0.0 install script.
remote:        npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote:        npm ERR! A complete log of this run can be found in:
remote:        npm ERR!     /tmp/npmcache.oPATN/_logs/2020-08-25T21_49_16_056Z-debug.log
remote:
remote: -----> Build failed

我该如何解决?

1 个答案:

答案 0 :(得分:0)

我仅将server.js文件从他的文件夹移动到与Heroku链接的新文件夹,而不复制node_modules文件夹,即可解决此问题, 然后我卸载了bcrypt库(在cmd中为“ npm uninstall bcrypt --save”)并安装了bcryptjs库。

现在命令“ git push heroku master”起作用。