当前位置:网站首页>错误: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
好的成功解决了问题。
所以说学习就是遇到问题,解决问题的过程,少年加油吧,相信你可以的。
边栏推荐
- 三谈exception——错误处理
- How to explain binary search to my sister? This is really difficult, fan!
- [technology development-22]: rapid overview of the application and development of network and communication technology-2-communication Technology
- How to modify the error of easydss on demand service sharing time?
- 屠榜多目标跟踪!BoT-SORT:稳健的关联多行人跟踪
- What are eNB, EPC and PGW?
- linux下清理系统缓存并释放内存
- 中文姓名提取(玩具代码——准头太小,权当玩闹)
- Clean up system cache and free memory under Linux
- 为什么switch 的default后面要跟break?
猜你喜欢
Unity SKFramework框架(十四)、Extension 扩展函数
Web基础
OpenFOAM:lduMatrix&lduAddressing
Pointer from entry to advanced (1)
Unity skframework framework (XIII), question module
屠榜多目标跟踪!BoT-SORT:稳健的关联多行人跟踪
诚邀青年创作者,一起在元宇宙里与投资人、创业者交流人生如何做选择……...
混沌工程平台 ChaosBlade-Box 新版重磅发布
Tupang multi-target tracking! BOT sort: robust correlated multi pedestrian tracking
Unity skframework Framework (XVI), package manager Development Kit Manager
随机推荐
不会看器件手册的工程师不是个好厨子
Partner cloud form strong upgrade! Pro version, more extraordinary!
Unity skframework framework (XXI), texture filter map resource filtering tool
Fundamentals of machine learning (II) -- division of training set and test set
Professor of Shanghai Jiaotong University: he Yuanjun - bounding box (containment / bounding box)
Chinese name extraction (toy code - accurate head is too small, right to play)
Achievements in science and Technology (27)
Why can't d link DLL
Solve "sub number integer", "jump happily", "turn on the light"
P3807 [template] Lucas theorem /lucas theorem
numpy数组计算
de4000h存储安装配置
[Unity]使用GB2312,打包后程序不正常解决方案
口袋奇兵点评
Skillfully use SSH to get through the Internet restrictions
JS reverse massive creative signature
文件的下载与图片的预览
【模板】最长公共子序列 (【DP or 贪心】板子)
Unity skframework framework (XIX), POI points of interest / information points
Performance optimization of memory function