Error installing package node-sass - npm

I always have same problem when installing node-sass
sudo npm install -g node-sass
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/max/Sites/xxxxxxx/node_modules/node-sass/build'
I have update my node and npm version but the same nothing to do, it seems something with permission.... any idea?

It seems like it is due to a problem with installing node-sass which is one of the dependencies.
It is due to the use of sudo while trying to install packages.
Read this https://docs.npmjs.com/getting-started/fixing-npm-permissions to see how to fix your permissions.

It looks like you're running into permission issues. If you are installing npm-packages then it might possible that you are getting an EACCES error when trying to install a package globally. This means you do not have permission to write to the directories npm uses to store global packages and commands.
You can change the directory permissions by running commands: sudo chmod u+x -R 775 ~/.npm and sudo chown $USER -R ~/.npm or you can just run any npm command with sudo, that should get resolve your issue.
If you are installing an npm-package locally, then you should be in your local project directory and can try running sudo npm install <pkg-name> command to install required package. the purpose of using sudo is that it will change your owner permissions so you can make your current user authorized to run npm commands.
I'd recommend you to take a look at https://docs.npmjs.com/getting-started/fixing-npm-permissions

If you run sudo npm install -g node-sass --unsafe-perm should fix your issue.

Related

EACCES: permission denied, open '/Users/stefma/.config/truffle/config.json' after installing Truffle

I tried literally all there is so far and I still can't run truffle macOS 11.6.
that's what I tried after of course first installing it with the command npm install -g truffle:
Downloading command line tools for Xcode and then installing with
sudo npm install -g truffle
sudo npm install --unsafe-perm=true --allow-root truffle
sudo chown myUsername:myUsername -R ~/.config
installing npm and node with nvm all over.
I'd be really grateful for any help
This should work kindly check [YourMacOSUserName] in fir place you MacOSUserName in it and please must rate my effort will be here for any further query.
sudo rm -rf /Users/[YourMacOSUserName]/Library/Preferences/netlify/
npm install -g netlify-cli
sudo ntl login

Gatsby : -bash: gatsby: command not found after npm install

When I try to install gatsby running npm install gatsby-cli -g , it does not work : when I run gatsby --help, it shows:
bash:gatsby command not found
I have tried:
uninstalling and reinstalling NPM
this gitHub solution : https://github.com/gatsbyjs/gatsby/issues/4967
I get a permission error when trying to change npm config set prefix /usr/local
I'm working on mac (version 10.14.5).
My environment details are as follows:
npm -v : 6.9.0
node -v : v10.16.0
What can I do to make it work?
Thanks in advance,
If it's a permissions error, you could use sudo npm install gatsby-cli -g to run it as a superuser. I have to do this when I install something globally.

npm install etherlime fails

I am trying to install etherlime on Ubuntu 16.04 and npm 6.5.0:
sudo npm install etherlime
Even if I run the above command with sudo it gives me this error:
npm ERR! code 1
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b master git://github.com/LimeChain/solidity-coverage.git /home/username/.npm/_cacache/tmp/git-clone-823333ab
npm ERR! /home/username/.npm/_cacache/tmp/git-clone-823333ab/.git: Permission denied
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /home/username/.npm/_logs/2019-01-07T08_00_45_775Z-debug.log
Try this one
npm i -g etherlime
or refer this link https://www.npmjs.com/package/etherlime
I've never used etherlime but you do not need to use sudo when using the npm command. Maybe npm is installed in a wrong way or You have an error due to the permissions of your directory.
Try with this:
sudo chown -R username directory.
I need the error logs to understand what the problem is, but remember to use npm in a sub-directory and not in the user's home directory.
mkdir folderName
cd folderName
npm install etherlime
You can found this answer useful.
Obviously before to try this You have to install etherlime globally (npm install -g etherlime)

Why I can't get NPM upgraded?

Here is how I install NPM on a Linux Mint 19.
sudo apt install nodejs
sudo apt install npm
The NPM version I get is 3.5.2, which is not the current version. To upgrade, I try the following commands.
sudo npm install latest-version
which has a few warning messages such as "not such file or directory, open '/home/me/package.json'"
and
sudo mpn install npm#latest -g
which runs without any warning or error messages.
The command
npm -v
still yields 3.5.2.
What is missing?
Also, the reason of using sudo in those upgrade commands is to work around some access permission.
try running:
which npm
and
sudo which npm
I suspect by running sudo apt-get ... you installed npm for your root user as opposed to your current user.
Try this command: npm install -g npm#latest or npm install -g npm#next
You can update NPM with: npm install -g npm.
See this Q&A for more variations that might occur/needed.

NPM -g update gives me many WARN dependency errors

Should I delete my node modules folder and reinstall everything again?
It appears that following David Walsh's way of updating Node has resolved my problem.
sudo npm cache clean -f
sudo npm install -g n
sudo n stable