angular install cli errno -13 [duplicate] - node.js

This question already has answers here:
Missing write access in mac to /usr/local/lib/node_modules
(9 answers)
npm install -g less does not work: EACCES: permission denied
(14 answers)
Closed 2 years ago.
i am trying to install npm install -g #angular/cli
and i get this error
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: '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).
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/admin/.npm/_logs/2019-08-04T05_20_10_235Z-debug.log
Tried following Commands repeatedly still did not worked.
1- i uninstall nodejs and reinstall old version
~ brew uninstall node
~ which node
~ rm -rf /usr/local/bin/node
~cd /usr/local/lib
~ sudo rm -rf node
~ sudo rm -rf node_modules
2- clean cash
~ npm cache verify --force
~ npm cache clear --force
~ npm uninstall -g #angular/cli
~ npm install -g #angular/cli
node version
v8.16.0
npm version
6.4.1

Since the latest version of Angular 8, it requires Node.js version 10.9.0 or later.
Upgrade Node.js on your OS.
Check at documentation to setup your environment : https://angular.io/guide/setup-local

From the error message it seems like a folder does not have write permission.
If you're on a windows machine, open a command prompt in "Run as Administrator" and execute the command.
If you're on a Mac, you'll have to give it permission using chmod 777 /usr/local/lib/node_modules

On linux, I had to use sudo npm install...

Related

I an facing this issue while installing the package cowsay globally. How do I fix it?

I had tried to install cowsay package globally with the help of npm, but I'm facing the following error.
npm i -g cowsay
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/cowsay
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/cowsay'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/cowsay'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/cowsay'
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!
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.
To get the list of directories and their owners:
ls -l
Find the folder that npm is installing to, change ownership permissions to your user. You can do that by:
sudo chown <user_id> <folder_name>
This will change the owner permissions of the given folder to your user. Now npm should install just fine.
Paste the following command and run it:
sudo chown -R $USER /usr/local/lib/node_modules/
After that run the original command:
npm i -g cowsay

Error: EACCES: permission denied, mkdir when installing sth with npm

Everytime I try to install something with npm (in this case electron-packager) I run into this error. How can I solve this issue?
I have already tried to give me access by changing the permissions on .npm via chmod, but it didn't work and I also tried it with another node version (installed via nvm: node -v 12.1.0; npm -v 6.9.0) and it didn`t work as well.
$ npm install electron-packager --save-dev
npm ERR! path /Users/felixmoser/.npm/_cacache/index-v5/15/a0
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir
npm ERR! Error: EACCES: permission denied, mkdir '/Users/felixmoser/.npm/_cacache/index-v5/15/a0'
npm ERR! [OperationalError: EACCES: permission denied, mkdir '/Users/felixmoser/.npm/_cacache/index-v5/15/a0'] {
npm ERR! cause: [Error: EACCES: permission denied, mkdir '/Users/felixmoser/.npm/_cacache/index-v5/15/a0'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/Users/felixmoser/.npm/_cacache/index-v5/15/a0'
npm ERR! },
npm ERR! isOperational: true,
npm ERR! stack: 'Error: EACCES: permission denied, mkdir ' +
npm ERR! "'/Users/felixmoser/.npm/_cacache/index-v5/15/a0'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/Users/felixmoser/.npm/_cacache/index-v5/15/a0',
npm ERR! parent: 'electron-packager'
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!
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).
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/felixmoser/.npm/_logs/2019-05-01T14_11_08_530Z-debug.log
I actually don't know what else I should try now and hope, that you guys can help me solve this problem!
change the ownership of .npm folder,
In my case I couldn't figure out the solution so I used
sudo chown -R $(whoami) ~/.npm
Just change the owner of ~/.npm folder to yourself:
sudo chown -R felixmoser ~/.npm
You'll need to enter your password for calling sudo.
There is also a similar problem with permissions when trying to install packages globally with --global or -g. I know it's not your current problem, but I want to add it here because people googling the EACCESS when doing a global install might reach this question as well.
Some people change the system folder privileges allowing non-root users writing in system folder, however here is what they recommend in the documentation:
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally/
Back up your computer (including it here because documentation mentions is too, but it feels to me overly cautious)
Then execute:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
Edit your ~/.profile:
export PATH=~/.npm-global/bin:$PATH
Then invoke it with
source ~/.profile
To test your new configuration, install a package globally without using sudo:
npm install -g jshint
Or instead of modifying ~/.profile just use the corresponding ENV variable (but to make it pernament you would have to modify the profile file anyway)
NPM_CONFIG_PREFIX=~/.npm-global
Simply add sudo
So instead of npm install electron-packager --save-dev
Let it be sudo npm install electron-packager --save-dev
Please consider running the instructions at least inside the user's location, for example:
/home/myuser/
express HelloWorld --view=pug

How to fix permission error while installing Parcel Bundler with terminal

while installing parcel module in nodeJS, via terminal on Mac OS i am getting permission error.
error: checkPermission Missing write access to /usr/local/lib/node_modules
i am new at learning Node Modules. i tried installing(Node , NPM) everything works perfect. but first time installing node module it throwing error. i know its looking for directory of Windows type URL but i don't know how to fix it for mac.
iMac:~ hassan$ node -v
v11.10.0
iMac:~ hassan$ npm -v
6.7.0
iMac:~ hassan$ npm install -g parcel-bundler
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).
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/hassan/.npm/_logs/2019-04-23T13_13_46_848Z-debug.log
i want to install Parcel Bundler for Ui animation on my website.
You'll need to have access to /usr/local/lib/node_modules as a super-admin has, to perform the global installation of parcel-bundler.
As mentionned in the comment and assuming your user is the list of sudoers for this computer, you can simply do :
sudo npm -g install parcel-bundler
If this is not the case, you'll need more permissions on the system to install Parcel. Then you'll be able to :
Add your user as a sudoers in the file sudoers.d (Be careful doing this ! See this tutorial for OSX).
Perform the operation directly as the super-admin of the computer.
I'd prefer the 1st option regarding the long-term administration and security of the computer itself. The other option, while not recommended, is still possible for some cases.
Otherwise, you'll not have permission errors if you choose to install Parcel locally. In this case, just omit the -g flag while running the command (i.e npm install parcel-bundler). It will end up by adding parcel to your package.json file so that you'll be able to install it again later.

error while installing "npm install -g ionic cordova"

When I install npm install -g ionic cordova It throws below error
npm WARN checkPermissions Missing write access to
/usr/lib/node_modules npm ERR! path /usr/lib/node_modules npm ERR!
code EACCES npm ERR! errno -13 npm ERR! syscall access npm ERR! Error:
EACCES: permission denied, access '/usr/lib/node_modules' npm ERR! {
Error: EACCES: permission denied, access '/usr/lib/node_modules' npm
ERR! stack: 'Error: EACCES: permission denied, access
\'/usr/lib/node_modules\'', npm ERR! errno: -13, npm ERR! code:
'EACCES', npm ERR! syscall: 'access', npm ERR! path:
'/usr/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).
npm ERR! A complete log of this run can be found in: npm ERR!
/home/javauser/.npm/_logs/2018-05-19T04_42_24_737Z-debug.log
I tried with root user as well.
I am using node v9.11.1 , npm 6.0.1
Never use npm with sudo (or as root)! You can create potential backdoor to your system.
I have just answered a very similar question in the following link: How to fix the problem with vue.js instalation
Basicaly what is happening is that NPM does not have the privileges to access /usr/local/lib. To give it access, you could change the ownership of ~/.npm in order to belong to your current user. This could be this way:
sudo chown -R $(whoami) ~/.npm
This way you do not have to run npm as sudo, which is not recomended. I believe that it is due to vulnerabilities that are known in npm packages.
Here is an article about it: Don't use "sudo" with npm "install"
run with sudo in Mac OS or linux
sudo npm install -g ionic cordova
or in windows open cmd with run as administrator
npm install -g ionic cordova

permissions installing yeoman with npm - eaccess?

I installed npm with homebrew and had to link it - i'm thinking this may be some part of the issue. This is all new to me so I am seeking any help. I am trying to install yeoman and some other things on a computer with
npm install -g yo
however it is spitting back the error -
npm ERR! Darwin 14.0.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "yo"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! path /Users/Lynda/npm-global/lib/node_modules/yo/lib
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! Error: EACCES, unlink '/Users/Lynda/npm-global/lib/node_modules/yo/lib'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES, unlink '/Users/Lynda/npm-global/lib/node_modules/yo/lib']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! path: '/Users/Lynda/npm-global/lib/node_modules/yo/lib' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! error rolling back Error: EACCES, unlink '/Users/Lynda/npm-global/lib/node_modules/yo/lib'
npm ERR! error rolling back at Error (native)
npm ERR! error rolling back { [Error: EACCES, unlink '/Users/Lynda/npm-global/lib/node_modules/yo/lib']
npm ERR! error rolling back errno: -13,
npm ERR! error rolling back code: 'EACCES',
npm ERR! error rolling back path: '/Users/Lynda/npm-global/lib/node_modules/yo/lib' }
I did a bunch of googling and can't find anything, could use some help! I'd like to avoid sudo'ing if I can. Thanks.
My preferred way of installing node & npm on OSX:
Install node via homebrew without npm:
brew update
brew install node --without-npm
echo prefix=~/.node >> ~/.npmrc
Then install npm via the install script on npmjs.org:
If you're wild and crazy:
curl -L https://www.npmjs.org/install.sh | sh
Otherwise, download https://www.npmjs.org/install.sh, inspect to your satisfaction, chmod +x and execute it.
Then add $HOME/.node/bin to your path.
Note: If you've previuously installed node + npm via the graphical installer or homebrew, you'll want to remove the previous install before installing again. For instance, if you installed via the graphical installer:
rm -rf /usr/local/lib/node_modules
rm -rf /usr/local/include/node
rm -rf ~/.npm
mv ~/.npmrc ~/.npmrc-old
you can own the directory that npm is trying to install to, I too disliked having to sudo. In fact, NPM states that you shouldn't sudo as well.
try:
sudo chown -R `whoami` /Users/Lynda/npm-global/lib/node_modules
remember that this will bind it to your current user, whoami is a bash variable to get your user name.
If you would like to avoid sudo'ing, I recommend you use a version manager for node such as nvm. This allows to install global packages without sudo and also to run different versions of node and/or io.js side by side.
If you see this:
npm ERR! Please try running this command again as root/Administrator.
Then sudo is probably exactly what you need to use. Try sudo npm install -g yo
As this line
npm ERR! Please try running this command again as root/Administrator
states, you need to have admin credentials to install the yeoman. So you can try with sudo npm install -g yo

Resources