我正在try 安装angular cli,但它显示我缺少对/usr/local/lib/node_模块的写入权限

 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).

推荐答案

在终端窗口中运行以下命令:

sudo chown -R $USER ~/.npm
sudo chown -R $USER /usr/lib/node_modules
sudo chown -R $USER /usr/local/lib/node_modules

Node.js相关问答推荐

无法在我的 node 项目中转让Google Drive v3 API中的所有权

nest js控制器方法调用两次

运行JEST测试时找不到模块&q;错误

如何使用多个OR参数从多个集合聚合

如何使用NodeJS在mongodb中更新文档

使用NodeJS通过服务账号列出Google Workspace用户

错误:无法为 /blog 收集页面数据并且在 object.fetch 处获取失败

错误:无法检测到网络(event="noNetwork",code=NETWORK_ERROR,version=providers/5.6.8)

使用 .pipe(res) 向客户端发送音频不允许您搜索?

node.js 中 res.setHeader 和 res.header 的区别

调用 require 时的 const vs let

使用 nvm-windows 时更新 npm

Connect/Express 中的session和cookieSession中间件有什么区别?

如何为 node.js 服务器分配域名?

从目录 node Js 中检索文件

AngularJS +sails.js

node.js(ES6 / Babel)中 import X 和 import * as X 的区别?

如何从 npm 注册表中删除 npm 包?

Mongoose:模式与模型?

我无法全局安装 nodemon,nodemon无法识别