我正在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相关问答推荐

如何在Mongoose for MongoDB中编写此查询

谷歌应用程序脚本UrlFetchApp和nodejs-axios返回不同的结果;MyFitnessPal日记

在 azure blob 容器之间复制文件

无法从 mongoDB 访问数据?

如何修复node.js中的错误代码无法加载资源:服务器响应状态为403(禁止)

如何在套接字对象中存储或添加数据?

Axios GET 返回不可读的响应

如何使用 Jest 模拟异步函数的延迟时间

在mongodb中只查询整数

多个 Axios 请求合并

制作一个接受命令行参数的脚本

使用restify时如何支持cors

如何在 NodeJs 中下载和解压缩内存中的 zip 文件?

npm 出现无法读取依赖项错误

遍历 NodeJS 中的一系列日期

如何从 findOneAndUpdate 方法中获取更新的文档?

nodeJS - 如何使用 express 创建和读取会话

Node.js - 使用异步库 - 带有对象的 async.foreach

找不到在 docker compose 环境中运行的 node js 应用程序的模块

Npm postinstall 仅用于开发