To install a Bootstrap theme I want to run npm install. However I always receive a permission denied error.
I already tried nvm
and then switched with
Check permissions of your project root with ls -l /Users/Marc/Desktop/Dev/masterclass/
. If the owner is not $USER
, delete your node_modules
directory, try changing the owner of that directory instead and run npm install
again.
cd /Users/Marc/Desktop/Dev
rm -rf ./masterclass/node_mdoules/
chown -R $USER ./masterclass/
cd masterclass
npm install
NPM_CONFIG_PREFIX=~/.npm-global
Copy this line into ur terminal, then hit enter. then install the necessary packages you need WITHOUT the term "sudo" in front of npm.
i.e.
npm install -g jshint
I entered the following:
cd /Users/Marc/Desktop/Dev
rm -rf ./masterclass/node_mdoules/
chown -R $USER ./masterclass/
cd masterclass
npm install
once this was completed the results indicated warnings and one notice instead of previous result of no permission and error.
I then entered the following:
% sudo npm install --global firebase-tools
my result was success upon completion of the last terminal entry.
I was having a similar issue, but the accepted answer did not work for me, so I will post my solution in case anyone else comes along needing it.
I was running npm install
in a project cloned from GitHub and during the clone, for whatever reason the write permission was not actually set on the project directory. To check if this is your problem, pull up Terminal and enter the following:
cd path/to/project/parent/directory
ls -l
If the directory has user write access, the output will include a w
in the first group of permissions:
drwxr-xr-x 15 user staff 480 Sep 10 12:21 project-name
This assumes that you're trying to access a project in the home directory structure of the current user. To make sure that the current user owns the project directory, follow the instructions in the accepted answer.
For me it was,
npm cache clean --force
rm -rf node_modules
npm install
I tried deleting manually but didn't help
For Mac;
Run this on the Terminal >
sudo chown -R $USER /usr/local/lib/node_modules