在nodeJS中安装包裹模块时,通过Mac上的终端,我得到了权限错误。错误: checkPermission缺少对/usr/local/lib/node_模块的写访问
我是学习节点模块的新手。我试着安装(Node,NPM),一切都很完美。但第一次安装节点模块时,它抛出错误。我知道它在寻找Windows类型URL的目录,但我不知道如何为mac修复它。
iMac:~ hassan$ node -v
v11.10.0
iMac:~ hassan$ npm -v
6.7.0
iMac:~ hassan$ npm install -g parcel-bundler
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR! stack:
npm ERR! "Error: EACCES: permission denied, access '/usr/local/lib/node_modules'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules' }
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/hassan/.npm/_logs/2019-04-23T13_13_46_848Z-debug.log
我想在我的网站上安装Ui动画软件包。
发布于 2019-04-23 15:05:16
您需要像超级管理员一样访问/usr/local/lib/node_modules
,以执行parcel-bundler
的全局安装。
正如评论中提到的,假设您的用户是这台计算机的sudoers列表,您可以简单地这样做:
sudo npm -g install parcel-bundler
如果不是这样的话,您将需要系统上更多的权限来安装Parcel。然后你就可以:
sudoers.d
中将用户添加为sudoers (请小心!)请参阅OSX的本教程 )。我更喜欢关于计算机本身的长期管理和安全的第一种选择。另一种选择虽然不建议,但在某些情况下仍然是可能的。
否则,如果选择在本地安装Parcel,则不会出现权限错误。在本例中,只需在运行命令时省略-g标志(即npm install parcel-bundler
)。它最终将添加包裹到您的package.json文件,以便您能够再次安装它以后。
https://stackoverflow.com/questions/55812369
复制相似问题