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 ...
随机推荐
- node.js开发 1-概述
https://www.cnblogs.com/gaoya666/p/9071288.html Nodejs英文网:https://nodejs.org/en/ 中文网:http://nodejs.c ...
- Install Gnome desktop
Install Gnome desktop http://www.dinggd.com/index.php/freebsd-8-0-rc1-gnome%E6%A1%8C%E9%9D%A2%E5%AE% ...
- HTML Marquee跑马灯
Marquee是html的标签,所有的主流浏览器都能兼容,用于创建文字滚动. 来介绍下标签的属性 滚动方向 direction <!--滚动方向 direction 4个值 up down le ...
- Vivado debug异常现象
前言 bit文件和ltx文件的信号位宽不匹配问题.用了dont_touch等属性没用... WARNING: [Labtools 27-1972] Mismatch between the desig ...
- C++线程同步与互斥之互斥体
抢红包练习 第一步:在第一个文本框中输入一个值,比如1000: 第二步:点击抢红包,同时创建3个线程,每个线程循环进行抢红包的操作,每次抢50; 第三步:使用Mutex进行线程控制,当第一个文本框中的 ...
- linux识别ntfs U盘
NTFS-3G 是一个开源的软件,可以实现 Linux.Free BSD.Mac OSX.NetBSD 和 Haiku 等操作系统中的 NTFS 读写支持 下载最新ntfs-3g源代码,编译安装 # ...
- 视觉AI风口一触即发,虹软AI沙龙点金深圳
7月26日,虹软AI沙龙在深圳湾科技生态园空间举办.AI沙龙是基于虹软视觉开放平台的开发者交流沙龙,旨在通过分享最新的实战案例,帮助开发者解决技术及落地难题,让技术更贴近实用场景. 本次活动中,深圳市 ...
- Linux磁盘管理——Ext2文件系统
前言 通常而言,对于一块新磁盘我们不是直接使用,而是先分区,分区完毕后格式化,格式化后OS才能使用这个文件系统.分区可能会涉及到MBR和GPT问题.至于格式化和文件系统又有什么关系? 这里的格式化指的 ...
- 使用virtualbox安装unbuntu开启共享文件夹时遇到的权限问题
在安装完虚拟机之后,开启文件夹共享,发现只能用root进行访问,个人帐号无权限: cust@hqjia-desktop:/media$ ll drwxr-xr-x 4 root root 4096 2 ...
- react-navigation 做导航栏,发现 Android 上的标题不居中
在做 React Native 应用的时候,我们常常使用 react-navigation 做导航栏,发现 Android 上的标题不居中,IOS 上没问题. 1 如果只有标题,那就在 headerT ...