首页 > 解决方案 > Bcrypt 拒绝安装;还没有修复工作

问题描述

这已经花费了几个月的时间进行故障排除。无论我尝试什么,我都无法 npm install bcrypt。

我已经尝试过sudo npm install bcryptbrew install bcrypt卸载节点并重新安装节点,复制 bcrypt 文件并编辑我的 json 文件......没有任何效果。使用 bcrypt 的替代品进行测试,例如 bcryptjs。这只是 bcrypt 包的问题,​​我已经尝试了几十个我在网上找到的建议和解决方案,但无济于事。

Brew 告诉我的 bcrypt 已安装,所以我通过 brew 卸载它,它说它仍然安装。我做了npm uninstall bcrypt -g以防万一,但它仍然不起作用。它说我无权访问我的 node_modules 文件夹,但同样,这只发生在 bcrypt 上,实际上没有别的。Express、postgresql、cors、body-parser、react、redux、thunk ......其他一切都可以安装和工作,没有任何问题。

npm WARN checkPermissions Missing write access to /Users/someUser/Desktop/realtorSite/server/node_modules
npm WARN server@1.0.0 No description
npm WARN server@1.0.0 No repository field.

npm ERR! path /Users/someUser/Desktop/realtorSite/server/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/Users/someUser/Desktop/realtorSite/server/node_modules'
npm ERR!  [Error: EACCES: permission denied, access '/Users/someUser/Desktop/realtorSite/server/node_modules'] {
npm ERR!   stack: 'Error: EACCES: permission denied, access ' +
npm ERR!     "'/Users/someUser/Desktop/realtorSite/server/node_modules'",
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/Users/someUser/Desktop/realtorSite/server/node_modules'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/someUser/.npm/_logs/2019-06-16T22_38_43_256Z-debug.log

我只是想弄清楚哪里出了问题,并且能够定期使用 bcrypt 和其他基于加密的软件包。

标签: javascriptnode.jsnpmbcrypt

解决方案


https://lightrains.com/blogs/fixing-npm-permissions-install-global

这个链接是我解决问题的方法。首先,我曾经npm config get prefix找到我的 npm 目录并cd ~进入我的根目录。然后我运行ls -a并在我的根目录中找到了一个 node_modules 文件夹。通过使用ls -la node_modules,我发现 root 被授予了所有权限,而我没有权限。sudo chown -R someUser node_modules将 node_modules 内的所有权限更改为 someUser 而不是 root。

经测试npm install bcrypt,安装没有问题。


推荐阅读