Please Try Running This Command Again as Root/administrator Npm Mac
I'thousand trying to install LESS on my machine and have installed node already. All the same, when I enter "node install -g less" I go the following error and am not sure what to exercise?
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: iii, npm ERR! code: 'EACCES', npm ERR! path: '/usr/local/lib/node_modules/less' } npm ERR! npm ERR! Delight endeavour running this control again equally root/Administrator. npm ERR! Organization Darwin 13.3.0 npm ERR! control "node" "/usr/local/bin/npm" "install" "-g" "less" npm ERR! cwd /usr/local/bin npm ERR! node -v v0.x.33 npm ERR! npm -v ane.four.28 npm ERR! path /usr/local/lib/node_modules/less npm ERR! code EACCES npm ERR! errno 3 npm ERR! stack Fault: EACCES, unlink '/usr/local/lib/node_modules/less' npm ERR! error rolling back Mistake: 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: three, npm ERR! error rolling back lawmaking: 'EACCES', npm ERR! error rolling back path: '/usr/local/lib/node_modules/less' } npm ERR! not ok code 0
This question is tagged with node.js
linux
less
~ Asked on 2014-10-28 fifteen:48:08
~ Answered on 2014-12-31 17:00:06
Honestly this is bad advice from npm
. An installation can run arbitrary scripts and running it with sudo
can be extremely dangerous! You could practise sudo npm install -g less
to install it globally, only instead I would recommend updating your npm settings:
#~/.npmrc prefix=~/.npm_modules
Then y'all tin can update your path:
#~/.bashrc or ~/.zshrc, etc. export PATH=$PATH:$HOME/.npm_modules/bin
Then you don't require root permissions to perform the installation and you tin can still use the binary.
This would but apply to your user, however. If you want the unabridged system to be able to use the module you lot would accept to tell everyone to add your path. More complicated and robust solutions would include adding a binder with node modules / binaries that a group could install to and adding that to anybody's path.
~ Answered on 2014-10-28 fifteen:57:05
Just prepend sudo
to the beginning of your command. As stated before, an installation runs some scripts that might be unsafe simply I saw installing globally helps a lot and is way simpler.
Run sudo npm install -g less
~ Answered on 2015-12-15 08:29:thirteen
This will definitely help. Answer past npm itself. https://docs.npmjs.com/getting-started/fixing-npm-permissions
Below is extracted from the URL for your convenience.
Choice 1: Change the permission to npm'due south default directory
-
Discover the path to npm'due south directory:
npm config become prefix
For many systems, this will exist /usr/local.
Alert: If the displayed path is just /usr, switch to Option ii or y'all will mess upward your permissions.
-
Alter the owner of npm'due south directories to the name of the current user (your username!):
sudo chown -R $(whoami) $(npm config become prefix)/{lib/node_modules,bin,share}
This changes the permissions of the sub-folders used by npm and some other tools (lib/node_modules, bin, and share).
Option 2: Change npm'due south default directory to another directory
-
Make a directory for global installations:
mkdir ~/.npm-global
-
Configure npm to use the new directory path:
npm config prepare prefix '~/.npm-global'
-
Open or create a ~/.profile file and add this line:
consign PATH=~/.npm-global/bin:$PATH
-
Back on the command line, update your system variables:
source ~/.contour
Examination: Download a package globally without using sudo.
`npm install -g jshint`
Instead of steps 2-4, you lot tin use the corresponding ENV variable (due east.g. if you don't want to modify ~/.profile
):
NPM_CONFIG_PREFIX=~/.npm-global
Selection 3: Use a package manager that takes care of this for you
If you lot're doing a fresh install of Node on Mac OS, yous tin can avoid this problem altogether past using the Homebrew package managing director. Homebrew sets things up out of the box with the correct permissions.
brew install node
~ Answered on 2017-10-31 17:52:41
I kept having this problem because windows was setting my node_modules
folder to Readonly. Make sure you uncheck this.
~ Answered on 2017-xi-fourteen 17:46:52
This is what I had to do to become started with a Less compiler to avoid problems as mentionned in the OP:
- Install node.js
- Install NPM with Terminal:
sudo npm install npm -g
- Install a Less compiler with Final:
sudo npm install -g less
(the sudo makes all the difference) - If you lot're using PHPstorm: Go to "Preferences… > Plugins" and install NodeJS-plugin (might need to "scan repositories" to find it) and restart PHPstorm (as prompted)
- After that get to Plugins once again: Install Less compiler (might demand to "browse repositories" to observe it) and restart PHPstorm (as prompted)
- In one case you have a project ready, go to "Settings > Tools > Filewatchers" and add "Less". The path (of the "Program") should read something like this:
/usr/local/bin/lessc
- Make sure Track only root files is checked in the settings of 6.
~ Answered on 2015-12-28 17:08:37
npm has an official page about fixing npm permissions when you get the EACCES (Error: Access) fault. The page even has a video.
Yous can gear up this problem using one of two options:
- Modify the permission to npm's default directory.
- Change npm'due south default directory to another directory.
~ Answered on 2016-03-10 03:00:55
I was getting this issue for instaling expo cli and I stock-still past merely post-obit four steps mentioned in the npm documentation hither.
Trouble is some version of npm fail to locate folder for global installations of package. Following these steps we tin can create or modify the .profile file in Home directory of user and give information technology a proper PATH there so it works similar a charm.
Try this it helped me and I spent around an hour for this issue. My node version was 6.0
Steps I follow
Back up your computer. On the command line, in your abode directory, create a directory for global installations:
mkdir ~/.npm-global
Configure npm to utilize 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:
consign PATH=~/.npm-global/bin:$PATH
On the command line, update your system variables:
source ~/.profile
To exam your new configuration, install a bundle globally without using sudo:
npm install -k jshint
~ Answered on 2020-10-16 07:47:20
In my instance i needed to update the npm version from 5.3.0 ? v.four.2 .
Earlier i could use this -- npm i -m npm
.. i needed to run two commands which perfectly solved my problem. Information technology is highly likely that it will even solve your problem.
Stride 1: sudo chown -R $USER /usr/local
Stride ii: npm install -grand cordova ionic
Subsequently this y'all should update your npm to latest version
Step three: npm i -g npm
Then yous are proficient to get. Hope This solves your problem. Thanks!!
~ Answered on 2017-09-24 03:35:52
I as well got the problem. This is what I did:
- Uninstalled nodeJs from Control Panel > Uninstall a program
- At that place are ii folders in users//appData/roaming --> npm folder and npm-cache binder. Delete both of these.
At present, go to nodeJS site, and install again. Select second choice in installation option (ie npm packet). Install it. You trouble must exist solved by at present.
~ Answered on 2017-09-28 10:48:47
I know this is an old questions but none of the solutions seemed similar a good practice hence I am putting how I have solved this outcome:
Tried solving this issue by using Homebrew but it was also installing node in /usr/local directory
which would over again cause EACCES
error.
Had to use a version manager like nvm for more than informations see the official npm guide.
For various operating organization.
nvm installs node and it's modules in the user's Domicile Binder thereby solving EACCES
bug.
~ Answered on 2018-05-29 11:54:22
Source: https://syntaxfix.com/question/7283/please-try-running-this-command-again-as-root-administrator-error-when-trying-to-install-less
0 Response to "Please Try Running This Command Again as Root/administrator Npm Mac"
Post a Comment