当前位置:网站首页>错误:EACCES:权限被拒绝,访问“/usr/lib/node_modules”
错误:EACCES:权限被拒绝,访问“/usr/lib/node_modules”
2022-07-02 10:17:00 【大前端之旅】
错误:EACCES:权限被拒绝,访问“/usr/lib/node_modules”
今天我在尝试使用 command 安装 typescript npm install -g typescript,它返回此错误:
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/n
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/n'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/n'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/n'
npm ERR! }
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!
具体报错

看完只有
那么有没有对应的解决办法呢,答案当然是有的,接下来看招
为全局安装创建一个目录:
mkdir ~/.npm-global
配置 npm 以使用新的目录路径:
npm config set prefix '~/.npm-global'
打开或创建一个 ~/.profile 文件并添加以下行:
open ~/.profile
export PATH=~/.npm-global/bin:$PATH
返回命令行,更新系统变量:
source ~/.profile
测试:在不使用 sudo 的情况下全局下载一个包。
npm install -g typescript
如果您使用的是 Z shell (Zsh),请添加export PATH=~/.npm-global/bin:$PATH到您的文件中~/.zshrc
好的成功解决了问题。
所以说学习就是遇到问题,解决问题的过程,少年加油吧,相信你可以的。
边栏推荐
- What are eNB, EPC and PGW?
- Node.js通过ODBC访问PostgreSQL数据库
- [Unity]使用GB2312,打包后程序不正常解决方案
- Web基础
- Professor of Shanghai Jiaotong University: he Yuanjun - bounding box (containment / bounding box)
- Partner cloud form strong upgrade! Pro version, more extraordinary!
- 二、帧模式 MPLS 操作
- Drawing Nyquist diagram with MATLAB
- Daily practice of C language --- monkeys divide peaches
- SSL证书的分类有哪些?如何选择合适的SSL证书?
猜你喜欢

Daily practice of C language --- monkeys divide peaches

The second anniversary of the three winged bird: the wings are getting richer and the take-off is just around the corner

2022 Heilongjiang provincial examination on the writing skills of Application Essays

What are eNB, EPC and PGW?

Web基础

Sum of the first n terms of Fibonacci (fast power of matrix)

Unity SKFramework框架(十五)、Singleton 单例

Node.js通过ODBC访问PostgreSQL数据库

Essential for operation and maintenance - Elk log analysis system

能自动更新的万能周报模板,有手就会用!
随机推荐
Japan bet on national luck: Web3.0, anyway, is not the first time to fail!
Bridge of undirected graph
Verification failed, please check your call back website. You can follow the instructions
Unity skframework framework (XIII), question module
OpenApi-Generator:简化RESTful API开发流程
JS逆向之巨量创意signature签名
Skillfully use SSH to get through the Internet restrictions
Daily practice of C language --- monkeys divide peaches
Let juicefs help you with "remote backup"
mac(macos Monterey12.2 m1) 个人使用php开发
解答:EasyDSS视频点播时音频是否可以设置为默认开启?
[Blue Bridge Cup] children's worship circle
Pointer from entry to advanced (1)
三翼鸟两周年:羽翼渐丰,腾飞指日可待
Can automatically update the universal weekly report template, you can use it with your hand!
[OpenGL] notes 29. Advanced lighting (specular highlights)
[Unity]使用GB2312,打包后程序不正常解决方案
[unity] using GB2312, the solution to abnormal program after packaging
伙伴云表格强势升级!Pro版,更非凡!
Explanation of 34 common terms on the Internet