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 ...
随机推荐
- ITIL《信息技术基础架构库》
一 概述 1. ITIL 自上世纪70年代开始,个人计算机以及计算机网络开始在欧美发达国家普及.随着时间的推移,信息系统的规模越来越大,人们对信息系统的依赖也越来越强.特别是到了80年代,互联网开始普 ...
- VS2017 配置 boost_1_70
1. 下载与安装 1.1 安装方法1 (1) 下载 https://www.boost.org/ 或者使用 https://sourceforge.net/projects/boost/files/b ...
- 服务端php之文件上传
知识点 echo $_SERVER['PHP_SELF']; 自动获取当前文件的路劲(即提交地址为当前页面) 当一个表单有文件域(即文件上传)的时候,method(提交方式)要设置post,这样更加安 ...
- springboot学习入门简易版七---springboot2.0使用@Async异步执行方法(17)
1启动类开启异步调用注解 @SpringBootApplication @EnableAsync //开启异步调用 public class StartApplication { 不开启则异步调用无效 ...
- 删除Ubuntu的UEFI启动项
bcdedit 删除 千万不要手贱用diskpart之类的命令直接删除文件夹,大写的没,有,用! 感谢这个视频的up主,youtube看不到请翻墙.https://www.youtube.com/wa ...
- 一个关于integer表示范围的问题
1:在做字符串parse为integer 类型市,一直出现问题就是当我parse “”2851663837”报错, 但是当我parse “1417585794” 可以.原来是超出integer 类型 ...
- Android笔记(四十五) Android中的数据存储——XML(一)DOM解析器
DOM解析XML在j2ee开发中比较常见,在Dom解析的过程中,是先把dom全部文件读入到内存中,然后使用dom的api遍历所有数据,检索想要的数据,这种方式显然是一种比较消耗内存的方式,对于像手机这 ...
- python两则99乘法表
分别应用while和for的嵌套循环,适用于初学的人看看 x = 1 while x <= 9: y = 1 while y <= x: print (y,'*',x,'=',x*y,en ...
- 程序员常用的3大Web安全漏洞防御解决方案:XSS、CSRF及SQL注入(图文详解)
https://blog.csdn.net/ChenRui_yz/article/details/86489067 随着互联网的普及,网络安全变得越来越重要,程序员需要掌握最基本的web安全防范,下面 ...
- Windows性能计数器监控实践
Windows性能计数器(Performance Counter)是Windows提供的一种系统功能,它能实时采集.分析系统内的应用程序.服务.驱动程序等的性能数据,以此来分析系统的瓶颈.监控组件的表 ...