【发布时间】:2019-09-12 16:58:10
【问题描述】:
在 nodeJS 中安装 parcel 模块时,通过 Mac OS 上的终端出现权限错误。 错误:checkPermission 缺少对 /usr/local/lib/node_modules 的写访问权限
我是学习节点模块的新手。我尝试安装(节点,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 动画安装 Parcel Bundler。
【问题讨论】:
-
如果你真的想全局安装包(即,使用 -g 标志),你需要使用
sudo npm install -g parcel-bundler。 -
同样的问题,但使用命令执行 sudo 会得到相同的结果。还尝试首先设置目录: sudo chown -R $USER ~/.npm sudo chown -R $USER /usr/lib/node_modules sudo chown -R $USER /usr/local/lib/node_modules (旁白;对不起,没有换行符,显然降价在这里不起作用?)
标签: node.js visual-studio npm parceljs