Npm Please Try Running This Command Again as Root/administrator

I'm trying to install LESS on my machine and have installed node already. However, when I enter "node install -k less" I get the following fault and am not sure what to do?

            FPaulMAC:bin paul$ npm install -grand less npm ERR! Mistake: 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! Please try running this control again as root/Administrator.  npm ERR! System Darwin 13.3.0 npm ERR! control "node" "/usr/local/bin/npm" "install" "-g" "less" npm ERR! cwd /usr/local/bin npm ERR! node -five v0.10.33 npm ERR! npm -five 1.4.28 npm ERR! path /usr/local/lib/node_modules/less npm ERR! code EACCES npm ERR! errno iii 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  { [Mistake: EACCES, unlink '/usr/local/lib/node_modules/less'] npm ERR! error rolling back   errno: 3, npm ERR! mistake rolling dorsum   code: 'EACCES', npm ERR! fault rolling back   path: '/usr/local/lib/node_modules/less' } npm ERR! not ok lawmaking 0                      

This question is tagged with node.js linux less

~ Asked on 2014-10-28 15:48:08

~ Answered on 2014-12-31 17:00:06

Honestly this is bad communication from npm. An installation can run arbitrary scripts and running it with sudo tin can be extremely unsafe! You lot could exercise sudo npm install -g less to install it globally, but instead I would recommend updating your npm settings:

            #~/.npmrc prefix=~/.npm_modules                      

Then y'all can update your path:

            #~/.bashrc or ~/.zshrc, etc. consign PATH=$PATH:$HOME/.npm_modules/bin                      

So you don't crave root permissions to perform the installation and you tin can still use the binary.

This would only apply to your user, however. If you desire the entire system to be able to utilize the module y'all 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.

~ 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 but I saw installing globally helps a lot and is mode simpler.

Run sudo npm install -thousand less

~ Answered on 2015-12-15 08:29:13

This will definitely assist. Respond by npm itself. https://docs.npmjs.com/getting-started/fixing-npm-permissions

Below is extracted from the URL for your convenience.


Choice ane: Change the permission to npm'southward default directory

  1. Detect the path to npm's directory:

    npm config go prefix

For many systems, this volition exist /usr/local.

Alert: If the displayed path is just /usr, switch to Option 2 or y'all volition mess upwards your permissions.

  1. Change the possessor of npm's directories to the proper noun of the current user (your username!):

    sudo chown -R $(whoami) $(npm config go 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'southward default directory to another directory

  1. Make a directory for global installations:

    mkdir ~/.npm-global

  2. Configure npm to apply the new directory path:

    npm config gear up prefix '~/.npm-global'

  3. Open or create a ~/.profile file and add this line:

    export PATH=~/.npm-global/bin:$PATH

  4. Dorsum on the command line, update your organization variables:

    source ~/.contour

Test: Download a packet globally without using sudo.

            `npm install -g jshint`                      

Instead of steps two-four, y'all tin can utilise the respective ENV variable (e.chiliad. if you don't desire to modify ~/.profile):

NPM_CONFIG_PREFIX=~/.npm-global


Selection 3: Apply a bundle manager that takes intendance of this for you

If y'all're doing a fresh install of Node on Mac Os, you can avoid this problem birthday by using the Homebrew package manager. Homebrew sets things upwards out of the box with the right 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.

enter image description here

~ Answered on 2017-11-xiv 17:46:52

This is what I had to practice to get started with a Less compiler to avoid issues as mentionned in the OP:

  1. Install node.js
  2. Install NPM with Terminal: sudo npm install npm -k
  3. Install a Less compiler with Terminal: sudo npm install -g less (the sudo makes all the difference)
  4. If you're using PHPstorm: Get to "Preferences… > Plugins" and install NodeJS-plugin (might need to "browse repositories" to find information technology) and restart PHPstorm (every bit prompted)
  5. Later that become to Plugins once again: Install Less compiler (might demand to "browse repositories" to find it) and restart PHPstorm (as prompted)
  6. Once y'all accept a project set up, go to "Settings > Tools > Filewatchers" and add together "Less". The path (of the "Program") should read something like this: /usr/local/bin/lessc
  7. Make certain Track just root files is checked in the settings of 6.

~ Answered on 2015-12-28 17:08:37

npm has an official page nigh fixing npm permissions when you get the EACCES (Error: Access) error. The page even has a video.

Yous can fix this trouble using one of two options:

  1. Change the permission to npm's default directory.
  2. Change npm'south default directory to another directory.

~ Answered on 2016-03-x 03:00:55

I was getting this upshot for instaling expo cli and I fixed by just post-obit 4 steps mentioned in the npm documentation hither.

Problem is some version of npm fail to locate folder for global installations of package. Following these steps we can create or modify the .contour file in Dwelling house directory of user and give it a proper PATH there so information technology works like a charm.

Try this it helped me and I spent around an hr for this issue. My node version was 6.0

Steps I follow

Back upward your figurer. On the command line, in your home directory, create a directory for global installations:

mkdir ~/.npm-global

Configure npm to utilize the new directory path:

npm config prepare 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 control line, update your system variables:

source ~/.profile

To test your new configuration, install a packet globally without using sudo:

npm install -grand jshint

~ Answered on 2020-10-16 07:47:20

In my case i needed to update the npm version from 5.three.0 ? 5.iv.2 .

Before i could use this -- npm i -k npm .. i needed to run two commands which perfectly solved my trouble. Information technology is highly likely that information technology will fifty-fifty solve your problem.

Step ane: sudo chown -R $USER /usr/local

Step 2: npm install -chiliad cordova ionic

After this y'all should update your npm to latest version

Step 3: npm i -g npm

Then you lot are practiced to become. Promise This solves your trouble. Thank you!!

~ Answered on 2017-09-24 03:35:52

I also got the trouble. This is what I did:

  1. Uninstalled nodeJs from Control Console > Uninstall a program
  2. At that place are ii folders in users//appData/roaming --> npm folder and npm-cache folder. Delete both of these.

At present, go to nodeJS site, and install again. Select 2nd pick in installation pick (ie npm package). Install information technology. You trouble must be solved by at present.

~ Answered on 2017-09-28 10:48:47

I know this is an erstwhile questions but none of the solutions seemed like a adept practice hence I am putting how I take solved this upshot:

Tried solving this issue by using Homebrew merely information technology was also installing node in /usr/local directory which would once more cause EACCES error.

Had to use a version manager like nvm for more than informations run into the official npm guide.

For diverse operating system.

nvm installs node and it's modules in the user'south HOME FOLDER thereby solving EACCES bug.

~ Answered on 2018-05-29 11:54:22

davistherveld.blogspot.com

Source: https://syntaxfix.com/question/7283/please-try-running-this-command-again-as-root-administrator-error-when-trying-to-install-less

0 Response to "Npm Please Try Running This Command Again as Root/administrator"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel