Error eacces permission denied rename

While trying to install a packge with npm (for example lodash) it fails with error message: npm ERR! Linux 3.4.0+ npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install&qu...

Resolving EACCES permissions errors when installing packages globally

If you see an EACCES error when you try to install a package globally, you can either:

  • Reinstall npm with a node version manager (recommended),

or

  • Manually change npm’s default directory

Reinstall npm with a node version manager This is the best way to avoid permissions issues. To reinstall npm with a node version manager, follow the steps in «Downloading and installing Node.js and npm». You do not need to remove your current version of npm or Node.js before installing a node version manager.

Manually change npm’s default directory

Note: This section does not apply to Microsoft Windows.

To minimize the chance of permissions errors, you can configure npm to use a different directory. In this example, you will create and use hidden directory in your home directory.

  1. Back up your computer.
  2. On the command line, in your home directory, create a directory for global installations:

mkdir ~/.npm-global

  1. Configure npm to use the new directory path:

npm config set prefix '~/.npm-global'

  1. In your preferred text editor, open or create a ~/.profile file and add this line:

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

  1. On the command line, update your system variables:

source ~/.profile

  1. To test your new configuration, install a package globally without using sudo:

npm install -g jshint Instead of steps 2-4, you can use the corresponding ENV variable (e.g. if you don’t want to modify ~/.profile):

NPM_CONFIG_PREFIX=~/.npm-global npx: an alternative to running global commands

If you are using npm version 5.2 or greater, you may want to consider npx as an alternative way to run global commands, especially if you only need a command occasionally. For more information, see this article about npx.

try set prefix out of c disk, such as npm config set prefix '/mnt/f/npm/.npm-global'

Содержание

  1. EACCES: permission denied when renaming file on extension installation #11641
  2. Comments
  3. Environment data
  4. Expected behaviour
  5. Actual behaviour
  6. Steps to reproduce:
  7. Error: EACCES: permission denied with npm – How to fix
  8. How to fix “Error: EACCES: permission denied with npm”
  9. 1. Reinstalling npm with a node version manager
  10. 2. Manually change npm’s default directory (Linux)
  11. Conclusion
  12. PREVENT YOUR SERVER FROM CRASHING!
  13. 1 Comment
  14. Error: EACCES: permission denied — Creating new gatsby app in WSL (Ubuntu 18.04) #21879
  15. Comments
  16. Description
  17. Steps to reproduce
  18. Expected result
  19. Actual result
  20. Environment
  21. Resolved Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’
  22. [Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’] < errno: -13, code: ‘EACCES’, syscall: ‘access’, path: ‘/usr/local/lib/node_modules’>
  23. Resolved Error: EACCES: permission denied
  24. Resolve ‘EACCES: permission denied’ problem:
  25. Change the user:
  26. Conclusion:
  27. Support our IDKBlogs team
  28. Welcome to IDKBlogs.

EACCES: permission denied when renaming file on extension installation #11641

Environment data

  • VS Code version: 1.44.2
  • Extension version (available under the Extensions sidebar): 2020.4.76186
  • OS and version: WSL Ubuntu
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6.9
  • Type of virtual environment used (N/A | venv | virtualenv | conda | . ): N/A
  • Relevant/affected Python packages and their versions: N/A
  • Relevant/affected Python-related VS Code extensions and their versions: N/A
  • Jedi or Language Server? (i.e. what is «python.jediEnabled» set to; more info

Expected behaviour

Extension installs without issue.

Actual behaviour

Extension fails to install in WSL and returns the error message:
EACCES: permission denied, rename ‘/home/moses/.vscode-server/extensions/.ms-python.python-2020.4.76186’ -> ‘/home/moses/.vscode-server/extensions/ms-python.python-2020.4.76186’

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. Navigate to the extension’s page in the extensions marketplace.
  2. Click the Install in WSL: Ubuntu button.

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help ; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging )

The text was updated successfully, but these errors were encountered:

Источник

Error: EACCES: permission denied with npm – How to fix

Stuck with “Error: EACCES: permission denied with npm”? We can help you.

This error is typically seen while trying to install a new npm package globally in a system.

Here at Bobcares, we often handle requests from our customers to fix similar errors as a part of our Server Management Services.

Today we will see how our support engineers fix this for our customers.

How to fix “Error: EACCES: permission denied with npm”

A typical error looks like the one given below:

We can either reinstall npm with a node version manager or manually change npm’s default directory.

1. Reinstalling npm with a node version manager

To publish and install packages to and from the public npm registry we must install Node.js and the npm command-line interface.

We can do this either with a Node version manager or a Node installer.

Note: npm Enterprise requires npm 4.4.x or greater. To download the latest version of npm, on the command line, run the following command:

The steps to follow are given below:

1. Checking version of npm and Node.js

We can use the following commands for this:

2. Using a Node version manager to install Node.js and npm

Node version managers allow us to install and switch between multiple versions of Node.js and npm.

Some of the OSX or Linux Node version managers are nvm and n. Likewise some of the Windows Node version managers are nodist and nvm-windows

3. Using a Node installer to install Node.js and npm

If we are unable to use a Node version manager, we can use a Node installer to install both Node.js and npm on our system.

OS X or Windows Node installers

We can use one of the installers from the Node.js download page. Also, we must ensure to install the version labeled LTS. Other versions have not yet been tested with npm.

Linux or other operating systems Node installers
If you’re using Linux or another operating system, use one of the following installers:

  • NodeSource installer.
  • One of the installers on the Node.js download page.

2. Manually change npm’s default directory (Linux)

To minimize the chance of permissions errors, we can configure npm to use a different directory.

In this example, we will create and use the hidden directory in the home directory.
Following are the steps to do:

1. Firstly, take a backup of the computer.

2. Then from the command line, in the home directory, we need to create a directory for global installations.

We can use the following:

3. For configuring npm to use the new directory path, we can use the following path:

4. Then, In a text editor, open or create a

/.profile file and add the following line:

5. After that we have to update the system variables using the following:

6. Now, to test the new configuration, install a package globally without using sudo :

[Need assistance? We can help you]

Conclusion

In short, we saw how our Support Techs fix “Error: EACCES: permission denied with npm” for our customers.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

Finally, something that works. Thank You!
(Linux Mint 20.3 Cinnamon)

Источник

Error: EACCES: permission denied — Creating new gatsby app in WSL (Ubuntu 18.04) #21879

Description

Hi, after installing gatsby globally in my WSL terminal i’m receiving the below error when running
gatsby new blog https://github.com/gatsbyjs/gatsby-starter-hello-world

Steps to reproduce

1.Install WSL Ubuntu 18.04
2.Curl install npm
3.Install gatsby with npm install -g gatsby-cli
4.New gatsby app with gatsby new blog https://github.com/gatsbyjs/gatsby-starter-hello-world

Expected result

Create a new app without an errors

Actual result

Environment

The text was updated successfully, but these errors were encountered:

@garethiv Also using WSL (Ubuntu 18.04.4)

gatsby: v2.19.23 and 2.19.22 (fail with error)

I started seeing:

I downgraded my version of Gatsby (v2.19.21) and it started working.

@talves that worked thanks a lot man!

For the gatsby team ref:

The issue is resolved as @talves pointed out by downgrading gatsby v to 2.19.21. It’s worth pointing out though that I still see warnings in the logs (below) and can see 2 reduxcache folders being created (unsure whether this is expected behaviour or not).

I’m also getting this error message on my WSL

warn Error persisting state: EACCES: permission denied, rename ‘reduxcacheN0NDd9’ -> ‘/home/. /Development/. /.docz/.cache/redux’

I’m trying to figure out if the .cache/redux reports are the same problem as the original report (despite the downgrade being a workaround). I’m the one who worked on the redux cache recently and the messages from the original issue here seem unrelated to those changes.

One thing you could try is to make sure that none of the folders have permission problems and that Gatsby isn’t called with elevated (sudo / root) priviledges. (And if you do, every call should be using the same user/permissions, but please use a regular user to run gatsby).

To get this try to sudo rm -rf node_modules

/.npm public .cache (from the project root) and then to run yarn; gatsby build . If the problem persists then the problem might be somehow related to the /tmp folder or the .cache folder’s original permissions and I’m not quite sure what might cause that.

Could somebody facing this problem please try hard dropping those folders and rerunning the build? Thanks!

I didn’t have the exact same problem but I did encounter the «error persisting state» problem (one message is printed to stdout every second) in development mode (but with the gatsby-remark-katex plugin) and also had tons of of reduxstate* directories created (looks like one «error persisting state» message correspond to one reduxstate* directory created). Maybe #20538 is relevant?

@huy-nguyen fwiw, the solution to your problem as posted in that issue does not seem to relate to cache handling at all. That said, the cache basically creates a temporary folder, stores the cache there, renames current cache to old, renames tmp folder to current cache, then drops old cache. If either of the first two renames fails then it’s likely the tmp folder is left behind, yeah. But you’re saying this is resolved by options.strict = «ignore» ? Because that’s very unexpected to me.

@pvdz doing a sudo rm -rf node_modules

/.npm public .cache and upgrading back to 2.9.23 does work for the .cache rename error

Next time, try to remove them one by one, see if there’s a particular folder causing this.

Also, do you know if you ever run nodejs stuff through sudo? (Or as root through other ways). That could cause this for a million different reasons.

I would never run nodejs commands through sudo, so that was not the case. I thought I should’ve ran those separately, but unfortunately, I already spent too much time chasing the error yesterday and figuring out what version was the issue.

I’m 🤞 there will not be a next time. If I do see it again, I will do one at a time to get the culprit for you.

@garethiv can you check whether removing the folders solves your problem as well? One by one would be nice (and if that doesn’t work, all at once, just in case) to help triage the source of this problem. Permission problems have a wide breadth of origins so it’s a little hard to tell what might cause it. But once permissions are inconsistent, it’s hard to get things done right.

@pvdz it does seem odd that we are fine with all those permissions with the change being ^2.9.22 , so can’t you determine the culprit from that change on the redux cache

@talves well, I wrote that whole change. There’s a few things at play but at its core it creates a new tmp folder, using a nodejs built in function for that. Then it generates a bunch of files inside that folder. Once that’s done it will rename the existing redux folder. It will rename the tmp folder to be the new redux folder (basically moving it there). It will then go ahead to rm -rf (rimraf) the old redux folder. It will also try to remove the legacy file, in case that matters.

So there are five places where this error may occur, as far as the change goes;

  • Creating the tmp folder (not getting the proper permissions on some platform?)
  • Renaming the existing .cache/redux folder to .cache/redux.bakxxx (maybe the existing folder has the wrong permissions or the .cache folder has the wrong permissions)
  • Renaming the tmp folder we created to be the new .cache/redux folder (this would fail if the previous rename failed, or if the folder we created has incorrect permissions, or outside potentially when the tmp folder has weird permissions preventing a rename)
  • Dropping the old cache folder (the symptoms don’t line up for this to be the problem)
  • Dropping the legacy cache file (dito)

I’m a little surprised there’s a few people reporting this, but it seems everybody that’s reporting it is on WSL. So my hunch would be that the tmp folder does not get the correct permissions. Maybe you can check this?

@pvdz hey I tried to delete one by one following the bellow steps:

1-Deleted .cache & ran gatsby develop > same error message & creation of redux folders
2-Deleted node_modules & ran npm install > got a bunch off different permission errors on something else this time (logs below) — I switched over to Windows CMD and everything worked fine (install & gatsby develop & no redux folders being created)

This makes me think it’s a problem with npm permissions in WSL but it’s not clear to me why i’m now not able to run npm install at all nor why gatsby develop worked fine after downgrading

Very strange indeed 🙁 One option is that the new changes to the cache inadvertedly cause incorrect permissions to be set somewhere in the chain. But they don’t (or at least, shouldn’t) change anything in the node_modules folder. It might just be a red herring and caused by a different change in the same set (although I remember there aren’t that many changes for that patch bump)

I wonder what’s trying to rename folders to add the suffix .DELETE to it. That’s definitely not my change. You posted a log that contained it, like first message, but for a different folder.

Could you paste the debug.log log that npm prints? Or well, I’m interested in the stack trace. What’s the source of this rename call.

I’m running gatsby with netlify dev inside of the VS Code terminal on macOS Catalina 10.15.3. Shortly after the project starts up (usually with gatsby clean && netlify dev ) I get an error like the one below and it continues creating «reduxcache» folders until I close the terminal

All of my work right now depends on netlify dev so I haven’t tried using gatsby develop without Netlify CLI to know if that’s part of the problem. I also haven’t tried recreating it with an example repo. Until I have a minute to do those I thought I’d chime in with a few details in case it’s helpful!

It might also be worth noting that Netlify CLI is constantly competing with Gatsby to log info to the terminal so it could also be hiding some more useful errors but I’m not sure how to surface those. Let me know if you have any questions or suggestions that could help solve this.

Источник

Resolved Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’

[Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’] < errno: -13, code: ‘EACCES’, syscall: ‘access’, path: ‘/usr/local/lib/node_modules’>

Shubham Verma July 24, 2020

ometime, while installing anything using npm, you can see the Error: Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’ on your CMD or Terminal who prevent the installation. In this article we will see about the issue «EACCES: permission denied».

Resolved Error: EACCES: permission denied

In this article, we will resolved the error: EACCES: permission denied, access ’/usr/local/lib/node_modules’, This error comes due to the correct permission of files or folder to do any specific operation like READ, WRITE etc.’,

Here I am trying to install the angular CLI but I was getting the error as:

see the below snapshot:

Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’

Resolve ‘EACCES: permission denied’ problem:

First you should check the file/folder permission by running below command:

See the snapshot:

Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’

You can see in the above snapshot, it is denying access just because of the node_module folder is owned by root
Now this permission needs to be changed by changing the root to your user, you need to know the current username of your system.
To get the username run the below command:

Now you can see the current username as:

Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’

Change the user:

Now its time to change the user (owner) and remove the problem.
To change the user (owner) of this folder, run the below command:

After this command, it will ask for password, enter the password and you’r done.

To confirm, check the below command to see the permission and user of that file/folder ( as you did earlier ):

See the snapshot:

Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’

Now your problem should be solved, let’s check by installing the angular CLI:

See the snapshot:

Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’

In the above image, you can see the Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’ is resolved now.

Conclusion:

In this article, we saw how we can resolve the Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’ problem and we can change the permission of any file/folder and also saw how we can get the current username of the system.

Support our IDKBlogs team

Welcome to IDKBlogs.

If our contents help you and you learned from this platform, please consider supporting what we do.

Источник

1. Purpose

In this post, I would demonstrate how to solve the following error when trying to create an react app using npx:

/usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npx-cli.js create-react-app .

You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.0).

We no longer support global installation of Create React App.

Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app

The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/

Done

2. The solution

2.1 Debug

According to the above error message, we probably installed the create-react-app package globally, let’s check:

➜  ~ create-react-app
zsh: command not found: create-react-app
➜  ~

It seems that we have not installed the creat-react-app globaly.

We can verify it by list all the globally installed packages:

So the create-react-app is not installed globally. Why the error message say that I have installed the package globally?

2.2 The path to success

So I searched a lot for the solution ,here is the trying process:

2.2.1 Trying to upgrade npm

But I got this error:

➜  ~ npm i -g [email protected]
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/npm
npm ERR! dest /usr/local/lib/node_modules/.npm-i9nnxROI
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'
npm ERR!  [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/usr/local/lib/node_modules/npm',
npm ERR!   dest: '/usr/local/lib/node_modules/.npm-i9nnxROI'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/bswen/.npm/_logs/2021-12-15T11_47_34_810Z-debug.log
➜  ~

It’s a permission problem, change it to run as root:

➜  ~ sudo npm i -g [email protected]
Password:

removed 8 packages, changed 24 packages, and audited 215 packages in 4s

10 packages are looking for funding
  run `npm fund` for details

3 moderate severity vulnerabilities

To address all issues, run:
  npm audit fix

Run `npm audit` for details.
➜  ~

Now check the npm/node version again:

➜  ~ npm version
{
  npm: '8.3.0',
  node: '17.1.0',
  v8: '9.5.172.25-node.13',
  uv: '1.42.0',
  zlib: '1.2.11',
  brotli: '1.0.9',
  ares: '1.18.1',
  modules: '102',
  nghttp2: '1.45.1',
  napi: '8',
  llhttp: '6.0.4',
  openssl: '3.0.0+quic',
  cldr: '39.0',
  icu: '69.1',
  tz: '2021a',
  unicode: '13.0',
  ngtcp2: '0.1.0-DEV',
  nghttp3: '0.1.0-DEV'
}

now try to create react project using webstorm again, still got this error:

/usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npx-cli.js create-react-app .

You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.0).

We no longer support global installation of Create React App.

Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app

The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/

Done

2.2.2 Trying to uninstall it globally

Though I do not installed the create-react-app globally, I still follow the instructions in the error message:

➜  WebstormProjects npm uninstall -g create-react-app

up to date, audited 1 package in 304ms

found 0 vulnerabilities
➜  WebstormProjects 

I even cleaned the cache, but still not work:

➜  WebstormProjects npm cache clean -f         
npm WARN using --force Recommended protections disabled.
➜  WebstormProjects npx create-react-app my-app

You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.0).

We no longer support global installation of Create React App.

Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app

The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/

➜  WebstormProjects 
2.2.3 Trying to install the create-react-app again

still not work:

➜  WebstormProjects npm i create-react-app

up to date, audited 139 packages in 6s

4 packages are looking for funding
  run `npm fund` for details

3 high severity vulnerabilities

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
➜  WebstormProjects 
2.2.4 Trying to downgrade node and npm to stable version
➜  WebstormProjects sudo n stable
  installing : node-v16.13.1
       mkdir : /usr/local/n/versions/node/16.13.1
       fetch : https://nodejs.org/dist/v16.13.1/node-v16.13.1-darwin-x64.tar.xz
   installed : v16.13.1 (with npm 8.1.2)
➜  WebstormProjects npm version

➜  WebstormProjects npm version
{
  npm: '8.1.2',
  node: '16.13.1',
  v8: '9.4.146.24-node.14',
  uv: '1.42.0',
  zlib: '1.2.11',
  brotli: '1.0.9',
  ares: '1.18.1',
  modules: '93',
  nghttp2: '1.45.1',
  napi: '8',
  llhttp: '6.0.4',
  openssl: '1.1.1l+quic',
  cldr: '39.0',
  icu: '69.1',
  tz: '2021a',
  unicode: '13.0',
  ngtcp2: '0.1.0-DEV',
  nghttp3: '0.1.0-DEV'
}


Then try again, still not work:

npx create-react-app my-app

You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.0).

We no longer support global installation of Create React App.

Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app

The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/

Done


2.3 The solution

Then I realize that I might have installed the create-react-app in the current directory, not globally, so I tried to uninstall it without -g option.

➜  WebstormProjects npm uninstall create-react-app

removed 63 packages, and audited 76 packages in 1s

found 0 vulnerabilities
➜  WebstormProjects 

Now try again to create react app:

➜  WebstormProjects npx create-react-app my-app      
Need to install the following packages:
  create-react-app
Ok to proceed? (y) y
npm WARN deprecated [email protected]: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.

Creating a new React app in /Users/bswen/WebstormProjects/my-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

⸨#####⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⸩ ⠸ idealTree:readable-stream: sill placeDep ROOT [email protected] OK for: readab

It works!

3. Summary

In this post, I demontrated how to solve the We no longer support global installation of Create React App problem when trying to create react app using npx create-react-app my-app, the key point is to check if you have installed the old version of create-react-app locally or globally, you should check it globally or locally . That’s it, thanks for your reading.

Stuck with “Error: EACCES: permission denied with npm”? We can help you.

This error is typically seen while trying to install a new npm package globally in a system.

Here at Bobcares, we often handle requests from our customers to fix similar errors as a part of our Server Management Services.

Today we will see how our support engineers fix this for our customers.

How to fix “Error: EACCES: permission denied with npm”

A typical error looks like the one given below:

npm ERR! Error: EACCES, open '/Users/letscodepare/.npm/-/all/.cache.json'
npm ERR! { [Error: EACCES, open '/Users/letscodepare/.npm/-/all/.cache.json']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/Users/letscodepare/.npm/-/all/.cache.json' }
npm ERR! Please try running this command again as root/Administrator.
.....
.....

We can either reinstall npm with a node version manager or manually change npm’s default directory.

1. Reinstalling npm with a node version manager

To publish and install packages to and from the public npm registry we must install Node.js and the npm command-line interface.

We can do this either with a Node version manager or a Node installer.

Note: npm Enterprise requires npm 4.4.x or greater. To download the latest version of npm, on the command line, run the following command:

npm install -g npm

The steps to follow are given below:

1. Checking version of npm and Node.js

We can use the following commands for this:

node -v
npm -v

2. Using a Node version manager to install Node.js and npm

Node version managers allow us to install and switch between multiple versions of Node.js and npm.

Some of the OSX or Linux Node version managers are nvm and n. Likewise some of the Windows Node version managers are nodist and nvm-windows

3. Using a Node installer to install Node.js and npm

If we are unable to use a Node version manager, we can use a Node installer to install both Node.js and npm on our system.

OS X or Windows Node installers

We can use one of the installers from the Node.js download page. Also, we must ensure to install the version labeled LTS. Other versions have not yet been tested with npm.

Linux or other operating systems Node installers
If you’re using Linux or another operating system, use one of the following installers:

  • NodeSource installer.
  • One of the installers on the Node.js download page.

2. Manually change npm’s default directory (Linux)

To minimize the chance of permissions errors, we can configure npm to use a different directory.

In this example, we will create and use the hidden directory in the home directory.
Following are the steps to do:

1. Firstly, take a backup of the computer.

2. Then from the command line, in the home directory, we need to create a directory for global installations.

We can use  the following:

mkdir ~/.npm-global

3. For configuring npm to use the new directory path, we can use the following path:

npm config set prefix '~/.npm-global'

4. Then, In a text editor, open or create a ~/.profile file and add the following line:

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

5. After that we have to update the system variables using the following:

source ~/.profile

6. Now, to test the new configuration, install a package globally without using sudo:

npm install -g jshint

[Need assistance? We can help you]

Conclusion

In short, we saw how our Support Techs fix “Error: EACCES: permission denied with npm” for our customers.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = «owonCMyG5nEQ0aD71QM»;

Typically when installing a new npm packages globally in your system, you will encounter an error something like Error: EACCESS permission denied something.

Don’t worry, it’s natural I’m here to help you to fix this kind of error.

To the Rescue

Normally I’m using node version manager (nvm) to handle my node versions, so I can easily switch to any version I prefer but we will not discuss it here. I’ll create a separate blog post for that on how to set up a multiple node version using NVM (node version manager).

So let’s take a look the error that most probably something like this below:

Error:

npm ERR! Error: EACCES, open '/Users/letscodepare/.npm/-/all/.cache.json'
npm ERR!  { [Error: EACCES, open '/Users/letscodepare/.npm/-/all/.cache.json']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/Users/letscodepare/.npm/-/all/.cache.json' }
npm ERR! Please try running this command again as root/Administrator.
.....
.....

Solution:

  1. Open up your favorite terminal and run this code
sudo chown -R $(whoami) ~/.npm

So what does it do?
To the Rescue

chown is a unix command which means «change owner». From that definition based on our code above we are going to change the owner of our folder ~/.npm which for sure the «root» user is applied.

We’re going to assign this folder recursively to our own username using this command whoami so that it will be easy to read and write anything we want.

NOTE: Somehow, even when we change the owner of ~/.npm folder, we still encounter an EACCES error. To Fix that, we should change the owner of our node_modules folder.

sudo chown -R $(whoami) /usr/local/lib/node_modules/

Voila

Now you can finally install npm packages without sudo.

Wait just wait

Next Featured

Explore our new Tips and Tricks tutorial.
Explore our Tips and Tricks

Voila!!!

I hope you enjoy our tutorial, Let me know incase you encounter any error I would love to answer that. Don’t forget to subscribe to my Youtube Channel at Let’s Code Pare — Youtube Channel

Buy Me A Coffee

Share Now

При установке пакета Nodejs Browsertime я получил следующую ошибку.

npm install browsertime -g
/usr/bin/browsertime -> /usr/lib/node_modules/browsertime/bin/browsertime.js

> @sitespeed.io/chromedriver@77.0.3865-40 install /usr/lib/node_modules/browsertime/node_modules/@sitespeed.io/chromedriver
> node install.js

(node:26690) UnhandledPromiseRejectionWarning: Error: Destination Folder must exist
    at DownloaderHelper.__validate (/usr/lib/node_modules/browsertime/node_modules/@sitespeed.io/chromedriver/node_modules/node-downloader-helper/dist/index.js:390:23)
    at new DownloaderHelper (/usr/lib/node_modules/browsertime/node_modules/@sitespeed.io/chromedriver/node_modules/node-downloader-helper/dist/index.js:61:20)
    at download (/usr/lib/node_modules/browsertime/node_modules/@sitespeed.io/chromedriver/install.js:68:18)
(node:26690) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:26690) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

> @sitespeed.io/geckodriver@0.26.0 install /usr/lib/node_modules/browsertime/node_modules/@sitespeed.io/geckodriver
> node install.js

(node:26701) UnhandledPromiseRejectionWarning: Error: Destination Folder must exist
    at DownloaderHelper.__validate (/usr/lib/node_modules/browsertime/node_modules/@sitespeed.io/geckodriver/node_modules/node-downloader-helper/dist/index.js:387:23)
    at new DownloaderHelper (/usr/lib/node_modules/browsertime/node_modules/@sitespeed.io/geckodriver/node_modules/node-downloader-helper/dist/index.js:61:20)
    at download (/usr/lib/node_modules/browsertime/node_modules/@sitespeed.io/geckodriver/install.js:73:18)
(node:26701) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:26701) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

> sharp@0.23.0 install /usr/lib/node_modules/browsertime/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

ERR! sharp EACCES: permission denied, mkdir '/root/.npm/_libvips'
info sharp Attempting to build from source via node-gyp but this may fail due to the above error
info sharp Please see https://sharp.pixelplumbing.com/page/install for required dependencies
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/11.15.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/browsertime/node_modules/sharp/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/browsertime/node_modules/sharp/.node-gyp'
gyp ERR! System Linux 3.10.0-957.27.2.el7.x86_64
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/lib/node_modules/browsertime/node_modules/sharp
gyp ERR! node -v v11.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.23.0 install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sharp@0.23.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

Я попробовал несколько вещей, но ничего не получалось.

После небольшого поиска я нашел документацию по npmjs и попробовал --unsafe-perm

npm install --unsafe-perm

Я надеюсь, что это вам тоже поможет.

Понравилась статья? Поделить с друзьями:
  • Error eacces permission denied access usr local lib
  • Error e8116 the operation has been aborted fix nothing you have aborted the operation yourself
  • Error e51 brother
  • Error e46 undefined external iar
  • Error e42 canon mp140