I run npm install lodash but it throws Error: EACCES: permission denied error. I know it is permission issue but as far as I know, sudo permission
Try using this: 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
Test installing package globally without using sudo, Hope it helps
node recommends executing following:
sudo chown -R $USER:$(id -gn $USER) /home/venkatesh/.config
If you execute
npm config
You will see something like this
│ npm update check failed │
│ Try running with sudo or get access │
│ to the local update config store via │
│ sudo chown -R $USER:$(id -gn $USER) /home/venkatesh/.config │
It worked for me.
From what i can see in your logs you posted:
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/home/rupesh/node_modules/lodash',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/home/rupesh/node_modules/lodash',
npm ERR! fstream_class: 'DirWriter',
directory /home/rupesh/node_modules/
doesn't have necessary permissions to create directory so run chown -r rupesh:rupesh /home/rupesh/node_modules/
this should solve it.
Just change the owner of the global node_modules
directory to be your user:
sudo chown -R $USER:$GROUP /usr/local/lib/node_modules
This command fix the issue. It worked for me:
sudo npm install -g --unsafe-perm=true --allow-root
It doesn't have write permissions for others
(r-x). Try with
chmod a+w <folder>
and repeat.