I'm trying to install LESS on my machine and have installed node already. However, when I enter "node install -g less" I get the following error and am not sure what to do?
FPaulMAC:bin paul$ npm install -g less
npm ERR! Error: EACCES, unlink '/usr/local/lib/node_modules/less'
npm ERR! { [Error: EACCES, unlink '/usr/local/lib/node_modules/less']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/less' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 13.3.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "less"
npm ERR! cwd /usr/local/bin
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! path /usr/local/lib/node_modules/less
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, unlink '/usr/local/lib/node_modules/less'
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/less'
npm ERR! error rolling back { [Error: EACCES, unlink '/usr/local/lib/node_modules/less']
npm ERR! error rolling back errno: 3,
npm ERR! error rolling back code: 'EACCES',
npm ERR! error rolling back path: '/usr/local/lib/node_modules/less' }
npm ERR! not ok code 0
I kept having this problem because windows was setting my
node_modules
folder to Readonly. Make sure you uncheck this.Just prepend
sudo
to the beginning of your command. As stated before, an installation runs some scripts that might be dangerous but I saw installing globally helps a lot and is way simpler.Run
sudo npm install -g less
Honestly this is bad advice from
npm
. An installation can run arbitrary scripts and running it withsudo
can be extremely dangerous! You could dosudo npm install -g less
to install it globally, but instead I would recommend updating your npm settings:Then you can update your path:
Then you don't require root permissions to perform the installation and you can still use the binary.
This would only apply to your user, however. If you want the entire system to be able to use the module you would have to tell everyone to add your path. More complicated and robust solutions would include adding a folder with node modules / binaries that a group could install to and adding that to everyone's path.
In my case i needed to update the npm version from 5.3.0 → 5.4.2 .
Before i could use this
-- npm i -g npm
.. i needed to run two commands which perfectly solved my problem. It is highly likely that it will even solve your problem.Step 1:
sudo chown -R $USER /usr/local
Step 2:
npm install -g cordova ionic
After this you should update your npm to latest version
Step 3:
npm i -g npm
Then you are good to go. Hope This solves your problem. Cheers!!
Re Explosion Pills "An installation can run arbitrary scripts and running it with sudo can be extremely dangerous!"
Seems like using sudo is the wrong way of doing it.
"Change the owner of the files in your /usr/local folder to the current user:"
Then run the install
Check out:
This is what I had to do to get started with a Less compiler to avoid issues as mentionned in the OP:
sudo npm install npm -g
sudo npm install -g less
(the sudo makes all the difference)/usr/local/bin/lessc