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
I tried most of these suggestions but none of them worked. Then I ran npm clean-install
and it solved my issues.
I have same issue with webpack server installation on globally, Use steps from this Url Solved my issue, my be work for you.
Steps mention above There: Back-up your computer before you start.
Make a directory for global installations:
1.
mkdir ~/.npm-global
Configure npm to use the new directory path:
2.
npm config set prefix '~/.npm-global'
Open or create a ~/.profile file and add this line:
3.
export PATH=~/.npm-global/bin:$PATH
Back on the command line, update your system variables:
4.
source ~/.profile
Test: Download 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
I solved this issue by changing the permission of my npm directory. I went to the npm global directory for me it was at
/home/<user-name>
I went to this directory by entering this command
cd /home/<user-name>
and then changed the permission of .npm folder by entering this command.
sudo chmod -R 777 ".npm"
It worked like a charm to me. But there is a security flaw with this i.e your global packages directory is accessible to all the levels.
Try to give all permission to your project folder with below command
sudo chmod -R 777 /yourProjectDirectoryName
run with
sudo npm install lodash
Creating package.json using npm init solved my issue.