node.js - npm 安装权限被拒绝 (macOS)

标签 node.js npm npm-install

要安装 Bootstrap 主题,我想运行 npm install。但是我总是收到权限被拒绝的错误。

我已经尝试过 nvm,然后切换到 nvm use 10.9.0 来运行 npm install

我还尝试了 sudo chown -R $(whoami) ~/.npmsudo chown -R $USER/usr/local/lib/node_modules。都没有解决它,现在我不知道如何继续。我使用 macOS High Sierra。

Marcs-MBP-3:masterclass Marc$ npm install
npm WARN deprecated gulp-uglifyjs@0.6.2: Since gulp-sourcemaps now works, use gulp-uglify instead
npm WARN deprecated babel-preset-es2015@6.24.1: 🙌  Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update! 
npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN checkPermissions Missing write access to /Users/Marc/Desktop/Dev/masterclass/node_modules
npm ERR! path /Users/Marc/Desktop/Dev/masterclass/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/Users/Marc/Desktop/Dev/masterclass/node_modules'
npm ERR!  { [Error: EACCES: permission denied, access '/Users/Marc/Desktop/Dev/masterclass/node_modules']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, access \'/Users/Marc/Desktop/Dev/masterclass/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/Users/Marc/Desktop/Dev/masterclass/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/Marc/.npm/_logs/2018-08-22T12_46_51_786Z-debug.log

最佳答案

对于苹果机;

在终端上运行它>

sudo chown -R $USER /usr/local/lib/node_modules

关于node.js - npm 安装权限被拒绝 (macOS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51967335/

相关文章:

npm-install - 我在安装任何节点模块时收到此错误。例如: This error occur while installing MUI Toolpad

node.js - 如何在 ubuntu 中将 npm 安装时间的等待超时从 30000 毫秒增加到 60000 毫秒

ajax - 来自 Node.js 的基本警报

c - NodeJS 退出代码左移 8 位

node.js - 使用 mongoosejs 进行 map 缩减

javascript - 使用 Bluebird 在 Promises 中包装 Node.js 回调

node.js - 运行 npm start 会使进程在当前端口上运行,无论是否结束它

sqlite - 将 npm 模块与 Electron 和 webpack 一起使用?

node.js - NPM:如何在无需调用 'git' 命令的情况下构建具有基于 git 的依赖项的项目?

node.js - NPM 安装在 Docker 容器内失败,但在带有企业代理的主机上运行