I am trying to install angular cli but it's show me Missing write access to /usr/local/lib/node_modules so, how can I fix it in my mac i try it may time but, not getting exact answer
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules' }
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!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
Run these commands in a terminal window:
sudo chown -R $USER ~/.npm
sudo chown -R $USER /usr/lib/node_modules
sudo chown -R $USER /usr/local/lib/node_modules
I had this issue, I could fixed it by calling sudo on every global install. I wasn't ok with that.
I followed the n package installation advices to be able to install npm packages without sudo.
sudo chown -R $(whoami) /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share
Answer of @jeduard didn't work for me.
Best way to solve your npm install -g
issues:
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
This way, you will never need to use SUDO
or change permissions
.
Quoting :
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 ~/.profile
file and add this line:
export PATH=~/.npm-global/bin:$PATH
On the command line, update your system variables:
source ~/.profile
Same problem. I reinstalled the latest version of node via https://nodejs.org/en/download/ instead of using terminal. This resolved the issue.
只需添加sudo
: sudo npm install -g @angular/cli
I had a similar issue when trying to install React -- issues with permissions being denied.
This is where SUDO can come in handy, it allows a permitted user to execute a command as the superuser or another user. Think of like "Run as Administrator" on Windows. If you type in the following command, it should allow you to access all of the needed folders with the proper elevated access.
sudo chown -R $(whoami) /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share
This is also denoted in Dimitri's answer: https://stackoverflow.com/a/60791736/3803726
如果您真的无法全局安装 NPM 模块(例如在某些公司笔记本电脑上),您可以将它们全部安装在某个地方的单个本地文件夹中,然后将 node_modules/.bin/ 的路径添加到您的 PATH 环境中。
ry appending sudo before whatever command you are trying.
like this : sudo npm install
Using sudo with a command in Linux/UNIX generally elevates your permissions to superuser levels. In Windows, the superuser account is usually called 'Administrator.' In Linux/Unix the superuser account is generally named 'root'.
The root user has permission to access, modify or delete almost any file on your computer. Normal user accounts can access, modify or delete many fewer files. The restrictions on a normal account protect your computer from unauthorized or harmful programs or users. Some processes require you to perform actions on files or folders you don't normally have permissions to access. Installing a program that everyone can access is one of these actions.
In your case, running the installation command with sudo gives you the permissions of the superuser, and allows you to modify files that your normal user doesn't have permission to modify.
我只是使用对我有用的sudo
和 FWIW 运行安装命令:)
For macOS try to run -
sudo chown -R $USER ~/.npm
sudo chown -R $USER /usr/local/lib/node_modules
sudo chown -R $USER /usr/local/bin/
If this still doesn't work you might need to add sudo to the npm install command.
很简单,运行下面的命令sudo chown -R $USER /usr/local/lib/node_modules
Try using on the terminal
su
It'll ask you for the password, then you can run the command above.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.