Resolving EACCES permissions errors when installing packages globally(npm 遇到 write access的问题)
If you see an EACCES error when you try to install a package globally, you can either:
- Reinstall npm with a node version manager (recommended),
or
- Manually change npm’s default directory
Reinstall npm with a node version manager§
This is the best way to avoid permissions issues. To reinstall npm with a node version manager, follow the steps in “Downloading and installing Node.js and npm”. You do not need to remove your current version of npm or Node.js before installing a node version manager.
Manually change npm’s default directory§
To minimize the chance of permissions errors, you can configure npm to use a different directory. In this example, you will create and use hidden directory in your home directory.
- Back up your computer.
- On the command line, in your home directory, create a directory for global installations:
mkdir ~/.npm-global
- Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
- In your preferred text editor, open or create a
~/.profilefile and add this line:export PATH=~/.npm-global/bin:$PATH
- On the command line, update your system variables:
source ~/.profile
- To test your new configuration, install a package globally without using
sudo:npm install -g jshint
Instead of steps 2-4, you can use the corresponding ENV variable (e.g. if you don’t want to modify ~/.profile):
NPM_CONFIG_PREFIX=~/.npm-global
# 第一步:在你的用户文件下新建一个文件夹,这个.npm-global 名字可以用你自己喜欢的名字替换,推荐直接使用这个名字。
mkdir ~/.npm-global
#第二步:更改node的安装连接
npm config set prefix '~/.npm-global'
#第三步:在用户的profile下增加path,为的是系统能够找到可执行文件的目录
export PATH=~/.npm-global/bin:$PATH
#第四步:update profile。使其生效
source ~/.profile
Resolving EACCES permissions errors when installing packages globally(npm 遇到 write access的问题)的更多相关文章
- xp安装vmware10时一直停在installing packages on the system
我估计的原因是: vm会在网上邻居(LAN或高速internet)下创建两个 vmware network adapter vmnet8 vmware network adapter vmnet1 ...
- Install packages failed: Installing packages: error occurred. ------简单的问题常常会被忽略
用 pip install 安装了wxpy这个库,但是使用的时候却报错:ImportError: No module named wxpy 我先用 pip list 查看了一下,发现这个库是已经存在的 ...
- [NPM] Publish npm packages using npm publish
In this lesson we will publish our package. We will first add a prepublish script that runs our buil ...
- NPM全局安装软件包时解决EACCES权限错误
NPM全局安装软件包时解决EACCES权限错误 Resolving EACCES permissions errors when installing packages globally npm WA ...
- 解决Mac下npm权限问题
前言 在学习Vue-CLI3的时候使用了全局安装,提示安装失败,本以为是npm版本问题,在更新npm的过程中又出现了 npm ERR! code: 'EACCES' ,查了一下发现是权限问题. 看到权 ...
- npm install 权限问题
npm ERR! Error: EACCES: permission denied, access '/Users/Lobin/work/note-vue/node_modules/@babel/hi ...
- Getting Started With Node and NPM
Getting Started with Node and NPM Let's start with the basics. Install Node.js: https://nodejs.org.
- [TypeScript] Using Typings and Loading From node_modules
Using TypeScript when installing packages from npm often requires you to install related definition ...
- browserify总结
一.browserify 简介 browserify is a tool for compiling node-flavored commonjs modules for the browser. Y ...
随机推荐
- Cookie 和 Session 总结
Cookie 和 Session 区别 cookie数据存放在客户的浏览器上,session数据放在服务器上 cookie不是很安全,别人可以分析存放在本地的cookie并进行cookie欺骗,考虑* ...
- sqlserver 汉字转拼音(转载)
转载来源一:https://www.cnblogs.com/zhuisuo/archive/2012/01/11/2318908.html 汉字转全拼音函数优化方案(SQLServer),值得你看看 ...
- 【idea】scala&sbt+idea+spark使用过程中问题汇总(不定期更新)
本地模式问题系列: 问题一:会报如下很多NoClassDefFoundError的错误,原因缺少相关依赖包 Exception in thread "main" java.lang ...
- web中cookie和session_转
转自:Python爬虫番外篇之Cookie和Session python修行路 关于cookie和session估计很多程序员面试的时候都会被问到,这两个概念在写web以及爬虫中都会涉及,并且两者可 ...
- linux系统编程面试题
说明:所有题目均摘录于网络以及我所见过的面试题目,欢迎补充! 无特殊说明情况下,下面所有题s目都是linux下的32位C程序. 1.堆和栈有什么区别? (1)栈由操作系统分配和释放:堆则是程序员手动去 ...
- Alternative method of unlocking the bootloader - without code from HUAWEI
原文:https://forum.xda-developers.com/p8lite/general/alternative-method-unlocking-bootloader-t3799294 ...
- 用js刷剑指offer(两个链表的第一个公共结点)
题目描述 输入两个链表,找出它们的第一个公共结点. 牛客网链接 js代码 /*function ListNode(x){ this.val = x; this.next = null; }*/ fun ...
- 使用BERT预训练模型+微调进行文本分类
本文记录使用BERT预训练模型,修改最顶层softmax层,微调几个epoch,进行文本分类任务. BERT源码 首先BERT源码来自谷歌官方tensorflow版:https://github.co ...
- HL7入门书
由我翻译HL7书,写给大忙人的HL7 链接:https://pan.baidu.com/s/16MkTj3EIDfFpqRCAIbiC2w 提取码:ndfw
- 51nod 2381 个人所得税
牛牛已知每月的税前收入,他想知道在新个税下,税收后收入是多少?个税计算方法是这样的: 综合所得金额 - 新起征点5000元 = 应纳税所得额 其中 综合所得金额 就是税前收入,(你可以忽略五险一金,专 ...