Error eacces permission denied unlink

Laravel Mix Version: 0.11.4 1 Node Version (node -v): v6.10.3 NPM Version (npm -v): 3.10.10. OS: Ubuntu Linux 16.04.2 Description: Settings up a demo vue project with this description: https://gith...

I am having this problem when running npm run prod from envoyer.io, on a forge managed EC2 instance I just launched like two weeks ago. Didn’t have this issue before, but then again, I didn’t have the copy command I added on my current failing deployment. When I added the copy to the mix it broke down with this permission error.

In my case, I am running the following:
laravel-mix:2.0.0
node:8.9.4
npm:5.6.0

The command is being run as the user forge on envoyer.io, the folders there are owned by the forge user and the permissions are normal as just set by forge originally… no issues with permissions anywhere else, except with this. Here’s my output… It would seem like there’s a permissions issue like Jeffrey says, (he’s definitely not wrong on that account) but this has to be the mother of all hidden permissions issues… I can’t see it.

> @ prod /home/forge/my-awesome-site.com/releases/20180215212737
> npm run production


> @ production /home/forge/my-awesome-site.com/releases/20180215212737
> cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

 DONE  Compiled successfully in 27276ms21:28:49

/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/fs-extra/lib/mkdirs/mkdirs-sync.js:49
          throw err0
          ^

Error: EACCES: permission denied, mkdir '/public'
    at Object.fs.mkdirSync (fs.js:885:18)
    at mkdirsSync (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/fs-extra/lib/mkdirs/mkdirs-sync.js:31:9)
    at Object.mkdirsSync (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/fs-extra/lib/mkdirs/mkdirs-sync.js:37:16)
    at Object.copySync (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/fs-extra/lib/copy-sync/copy-sync.js:49:37)
    at File.copyTo (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/laravel-mix/src/File.js:210:12)
    at FileCollection.copyTo (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/laravel-mix/src/FileCollection.js:88:24)
    at src.forEach.file (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/laravel-mix/src/FileCollection.js:82:38)
    at Array.forEach (<anonymous>)
    at FileCollection.copyTo (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/laravel-mix/src/FileCollection.js:82:17)
    at CopyFilesTask.run (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/laravel-mix/src/tasks/CopyFilesTask.js:14:20)
    at CustomTasksPlugin.runTask (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/laravel-mix/src/plugins/CustomTasksPlugin.js:34:14)
    at Mix.tasks.forEach.task (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/laravel-mix/src/plugins/CustomTasksPlugin.js:9:44)
    at Array.forEach (<anonymous>)
    at Compiler.compiler.plugin.stats (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/laravel-mix/src/plugins/CustomTasksPlugin.js:9:23)
    at Compiler.applyPlugins (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/tapable/lib/Tapable.js:61:14)
    at emitRecords.err (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/webpack/lib/Compiler.js:264:11)
    at Compiler.emitRecords (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/webpack/lib/Compiler.js:371:38)
    at emitAssets.err (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/webpack/lib/Compiler.js:258:10)
    at applyPluginsAsyncSeries1.err (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/webpack/lib/Compiler.js:364:12)
    at next (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/tapable/lib/Tapable.js:218:11)
    at Compiler.compiler.plugin (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
    at Compiler.applyPluginsAsyncSeries1 (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/tapable/lib/Tapable.js:222:13)
    at Compiler.afterEmit (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/webpack/lib/Compiler.js:361:9)
    at require.forEach.err (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/webpack/lib/Compiler.js:350:15)
    at /home/forge/my-awesome-site.com/releases/20180215212737/node_modules/async/dist/async.js:473:16
    at iteratorCallback (/home/forge/my-awesome-site.com/releases/20180215212737/node_modules/async/dist/async.js:1050:13)
    at /home/forge/my-awesome-site.com/releases/20180215212737/node_modules/async/dist/async.js:958:16
    at /home/forge/my-awesome-site.com/releases/20180215212737/node_modules/cacache/node_modules/graceful-fs/graceful-fs.js:43:10
    at /home/forge/my-awesome-site.com/releases/20180215212737/node_modules/enhanced-resolve/node_modules/graceful-fs/graceful-fs.js:43:10
    at /home/forge/my-awesome-site.com/releases/20180215212737/node_modules/readdirp/node_modules/graceful-fs/graceful-fs.js:43:10
    at /home/forge/my-awesome-site.com/releases/20180215212737/node_modules/jsonfile/node_modules/graceful-fs/graceful-fs.js:43:10
    at /home/forge/my-awesome-site.com/releases/20180215212737/node_modules/fs-extra/node_modules/graceful-fs/graceful-fs.js:43:10
    at /home/forge/my-awesome-site.com/releases/20180215212737/node_modules/yargs/node_modules/graceful-fs/graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:135:15)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ production script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

What my mix.copy() is trying to do is throw some font files into the public/fonts folder. These folders are both writable… (permissions for the fonts folder, similar to the public folder different number of links is all) drwxrwxr-x 3 forge forge and owned by the user executing the npm run prod command, so I am at a loss in figuring out the permissions mess here…

It is also happening locally, only for this project. I haven’t seen this behavior on other projects, will try rolling back mix versions to see if that does anything… (doubting it a lot, but something’s gotta give…)

Содержание

  1. EACCES: permission denied, unlink #58
  2. Comments
  3. on the working machine:
  4. on the erroring machine:
  5. [BUG] EACCES: permission denied, unlink ‘/usr/local/bin/code-server’ #1215
  6. Comments
  7. Description
  8. Steps to Reproduce
  9. NPM Install — Resolving EACCES Permissions Denied
  10. How to resolve eacces permissions denied when installing npm packages globally. Here’s how you solve this issue in a couple of minutes.
  11. Error:
  12. Solution:
  13. Voila
  14. Next Featured
  15. Voila.
  16. Resolving EACCES permissions errors when installing packages globally
  17. Resolved Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’
  18. [Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’] < errno: -13, code: ‘EACCES’, syscall: ‘access’, path: ‘/usr/local/lib/node_modules’>
  19. Resolved Error: EACCES: permission denied
  20. Resolve ‘EACCES: permission denied’ problem:
  21. Change the user:
  22. Conclusion:
  23. Support our IDKBlogs team
  24. Welcome to IDKBlogs.

EACCES: permission denied, unlink #58

Hit this error today in latest node-cpp-skel work: mapbox/node-cpp-skel#118

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

tl;dr it looks like this is happening because we’re trying to delete a symlink that points to a symlink that points to a directory that is owned by root: drwxr-xr-x 123 root wheel . On a machine where this directory is owned by the user running the process the error does not happen.

Started debugging this on a machine that is hitting it and another that is not. It looks like what is happening is that:

  • /mason_packages/.link/include/c++ is a symlink to mason_packages/osx-x86_64/clang-tidy/6.0.0/include/c++
  • mason_packages/osx-x86_64/clang-tidy/6.0.0/include/c++ is a symlink to /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++

The permissions on the machine that is hitting the error are:

The permissions on the machine that is not hitting an error are:

This is what it looks like to try to mimic the nodejs unlink that is failing:

on the working machine:

on the erroring machine:

And if I try to delete the directory:

It actually does unlink without an error (on the machine that nodejs is throwing an error). Odd!

Also two different packages are trying to link this symlink:

Источник

[BUG] EACCES: permission denied, unlink ‘/usr/local/bin/code-server’ #1215

  • code-server version: latest (dockerhub image)

Description

An eacces error happens when you try and upgrade code from within UI. Also can show up when you have selected updates disabled.

EACCES: permission denied, unlink ‘/usr/local/bin/code-server’

Steps to Reproduce

  1. docker run -p 8080:8080 -v «$/.local/share/code-server:/home/coder/.local/share/code-server» -v «$PWD:/home/coder/project» -d codercom/code-server:v2
  2. in browser type: http://localhost:8080
  3. bottom left of screen you will see a (1) in notifications, click it and will try and upgrade
  4. bottom right then you get a notification and clicking on it gives the above error.

This is caused because code is running a coder user (which is how it should be done) however the file is located in /usr/local/bin and owned by root. Coder does not have access to unlink (remove/replace) this thus the error happens.

A good solution IMHO would be to place the code-server binary in /home/coder/bin for example and chown it to the coder user and then adjust the ENTRYPOINT to the new path.

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

Could you elaborate a little more for those of us not to familiar with docker. I’ve tried creating a folder in /usr/local/bin and chown to the user running docker but still same issue.

Hi @cjazinski sorry I didn’t see this message till today due to all my GH notifications goes to my works address and I’ve not opened up works laptop till today.

After work, assuming got some time today ile do some test code for you to test.

Can you please give me the build tags/cmd your using as I’m having problems building what you have here (unusual) and sadly I don’t know yarn too much to debug quickly.

Have tried a few variants of below which should have worked from what I can see as your codeServerVersion defaults in the dockerfile as docker . You can see it entered values correctly.

Once this is building with what you currently have, it shouldn’t be rocket science to make this change.

Could you elaborate a little more for those of us not to familiar with docker. I’ve tried creating a folder in /usr/local/bin and chown to the user running docker but still same issue.

I tried this way, it doesn’t work as well. And I even moved the code-server to another folder and create a link there, but still doesn’t work. I guess the update script has some problem?

As I couldn’t get the docker build to build as tags etc wasn’t supplied, I decided to create the same thing but on a VM instead for a few of my friends.

I can confirm doing exactly what I said works:

Each user now can update their own code-server from the UI and there is no longer any errors.

Extra tweak, save admin (me) to restart my mates instances if they want to change their password, they just need to change their password in

/.env and incron will restart the process.

Theres no reason I can see why the same sort of thing wouldn’t work in docker. I don’t mind sorting it if someone can share how to build these images as the tags needed are a bit «weird».

Источник

NPM Install — Resolving EACCES Permissions Denied

How to resolve eacces permissions denied when installing npm packages globally. Here’s how you solve this issue in a couple of minutes.

npm tips and tricks eaccess permission denied

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.

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:

Solution:

  1. Open up your favorite terminal and run this code

So what does it do?

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.

Voila

Now you can finally install npm packages without sudo.

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

Источник

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.

Back up your computer.

On the command line, in your home directory, create a directory for global installations:

Configure npm to use the new directory path:

In your preferred text editor, open or create a

/.profile file and add this line:

On the command line, update your system variables:

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

Instead of steps 3-5, you can use the corresponding ENV variable (e.g. if you don’t want to modify

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.

Источник

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.

Источник

I found this error when creating a jhipster project with npm, and first trying to install the node generator-jhipster library with:

npm install -g generator-jhipster

The error detail is as follows:

[operatorfeitam@dev01 client01-app-project]$ npm install -g generator-jhipster
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm ERR! path /usr/local/bin/jhipster
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall unlink
npm ERR! Error: EACCES: permission denied, unlink '/usr/local/bin/jhipster'
npm ERR!  { [Error: EACCES: permission denied, unlink '/usr/local/bin/jhipster']
npm ERR!   cause:
npm ERR!    { Error: EACCES: permission denied, unlink '/usr/local/bin/jhipster'
npm ERR!      errno: -13,
npm ERR!      code: 'EACCES',
npm ERR!      syscall: 'unlink',
npm ERR!      path: '/usr/local/bin/jhipster' },
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, unlink '/usr/local/bin/jhipster'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'unlink',
npm ERR!   path: '/usr/local/bin/jhipster' }
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 (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/operatorfeitam/.npm/_logs/2020-11-22T10_17_16_979Z-debug.log

This is because the /usr/local/lib/nodes_modules directory (where global node libraries are installed by default) is root and does not have permissions by the user who ran the command with npm to install or access installed packages.

Before fixing it we confirm that it is by the above looking at the configuration that we have in node with:

npm config list

Which in my case returns to me:

[operatorfeitam@dev01 ~]$ npm config list
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.9.0 node/v10.16.2 linux x64"

; node bin location = /usr/local/bin/node
; cwd = /home/operatorfeitam
; HOME = /home/operatorfeitam
; "npm config ls -l" to show all defaults.

[operatorfeitam@dev01 ~]$ 

We see that the location of the node binary is in the usual default folder /usr/local/bin, and that a node v10.16.2 version is used. Now we check where the global libraries are installed with the command:

npm list -g | head -1

or:

npm list -g

This command returns in my case:

[operatorfeitam@dev01 bin]$ npm list -g
/usr/local/lib
├─┬ create-react-app@2.1.8
│ ├─┬ chalk@1.1.3
│ │ ├── ansi-styles@2.2.1
│ │ ├── escape-string-regexp@1.0.5
│ │ ├─┬ has-ansi@2.0.0
│ │ │ └── ansi-regex@2.1.1
│ │ ├─┬ strip-ansi@3.0.1
│ │ │ └── ansi-regex@2.1.1 deduped
│ │ └── supports-color@2.0.0
│ ├── commander@2.18.0
│ ├─┬ cross-spawn@4.0.2
...
...
  ├─┬ worker-farm@1.6.0
  │ └─┬ errno@0.1.7
  │   └── prr@1.0.1
  └─┬ write-file-atomic@2.4.2
    ├── graceful-fs@4.1.15 deduped
    ├── imurmurhash@0.1.4 deduped
    └── signal-exit@3.0.2 deduped

[operatorfeitam@dev01 bin]$ 

Note: With the command ‘npm list -g’ you get on the first line this location and all the global libraries installed. The ‘npm list’ command gets the non-global libraries that will be installed in a subfolder named node_modules from the location you are in when you run the npm installation command.

The previous command returns that the global library installation folder named node_modules located in /usr/local/lib. And if we therefore check who owns this path /usr/local/lib/node_modules see the source of the problem: it is owned by the root user.

[operatorfeitam@dev01 lib]$ pwd
/usr/local/lib
[operatorfeitam@dev01 lib]$ ls -la
total 8
drwxr-xr-x.  4 root root   41 Sep 20 19:34 .
drwxr-xr-x. 14 root root 4096 Nov 15  2018 ..
drwxrwxrwx.  7 root root 4096 Nov 22 11:17 node_modules
drwxr-xr-x.  3 root root   26 Sep 20 19:34 python3.6
[operatorfeitam@dev01 lib]$ 

The «prefix» attribute of the configuration that can be seen with the command ‘npm config ls -l’, which displays all the default values that the ‘npm config list’ command does not return, is the one that specifies where the global libraries are located that is in {prefix}/lib/node_modules. And the binaries in {prefix}/bin and the man pages in {prefix}/share/man.

If we see the value of «prefix» with the command:

npm config ls -l | grep prefix

gives us back:

[operatorfeitam@dev01 lib]$ npm config ls -l | grep prefix
prefix = "/usr/local"
save-prefix = "^"
tag-version-prefix = "v"
[operatorfeitam@dev01 lib]$ 

That matches what we’ve seen before, and that we’ve checked for the root user’s node_modules prefix/lib/node_modules.

The solution is to create a folder in the user’s home, to avoid permission issues, which has the problem locating the installation of global node libraries for that user.

For this we create a hidden folder with the name .npm-usr-local (can be any name) in the user’s home with the command:

mkdir ~/.npm-usr-local

Then we specify the «prefix» attribute in the node configuration with the command:

npm config set prefix '~/.npm-usr-local' 

Then in the .bash_profile file in the case of CentOS or .profile or counterpart in other linux distributions we add to the PATH the bin of this created folder which is where the binaries of the global libraries will be installed:

We reload the system variables by running the following command to reload the .bash_profile:

source ~/.bash_profile

We verify that the ‘npm config list’ command now gives us the new value of the «prefix» attribute:

And now we can install the generator-jhipster node library:

[operatorfeitam@dev01 client01-app-project]$ npm install -g generator-jhipster
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
/home/operatorfeitam/.npm-usr-local/bin/jhipster -> /home/operatorfeitam/.npm-usr-local/lib/node_modules/generator-jhipster/cli/jhipster.js

> ejs@2.7.4 postinstall /home/operatorfeitam/.npm-usr-local/lib/node_modules/generator-jhipster/node_modules/mem-fs-editor/node_modules/ejs
> node ./postinstall.js

Thank you for installing EJS: built with the Jake JavaScript build tool (https://jakejs.com/)


> spawn-sync@1.0.15 postinstall /home/operatorfeitam/.npm-usr-local/lib/node_modules/generator-jhipster/node_modules/spawn-sync
> node postinstall


> ejs@3.1.3 postinstall /home/operatorfeitam/.npm-usr-local/lib/node_modules/generator-jhipster/node_modules/ejs
> node --harmony ./postinstall.js

Thank you for installing EJS: built with the Jake JavaScript build tool (https://jakejs.com/)

+ generator-jhipster@6.10.5
added 705 packages from 479 contributors in 23.214s
[operatorfeitam@dev01 client01-app-project]$ 

All that remains is to run ‘npm list -g’ again where we will see that the new path specified in «prefix» is used with the generator-jhipster library installed and its dependencies

And if we access the .npm-user-local folder we see that it already has a bin and lib directory that has been created and that contain the libraries and binary installed previously.

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

Олег Рязанцев

Приветствую!
Не получилось сделать npm link без sudo.
npm link выдавал ошибку прав доступа к папке.
Какие права доступа надо дать в этом случае папке с проектом и как?

MacBook-Air-MacBook:frontend-project-lvl1 macbook$ npm link
npm ERR! code EACCES
npm ERR! syscall unlink
npm ERR! path /usr/local/lib/node_modules/frontend-project-lvl1_rain
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, unlink '/usr/local/lib/node_modules/frontend-project-lvl1_rain'
npm ERR!  { [Error: EACCES: permission denied, unlink '/usr/local/lib/node_modules/frontend-project-lvl1_rain']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, unlink '/usr/local/lib/node_modules/frontend-project-lvl1_rain'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'unlink',
npm ERR!   path: '/usr/local/lib/node_modules/frontend-project-lvl1_rain' }
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.


12


0

Сергей К.

Проверьте владельца на директории, которые указаны в сообщении об ошибке.


0

Олег Рязанцев

MacBook-Air-MacBook:node_modules macbook$ ls -l /usr/local/lib/node_modules/frontend-project-lvl1_rain
lrwxr-xr-x  1 root  wheel  54 14 ноя 21:31 /usr/local/lib/node_modules/frontend-project-lvl1_rain -> /Users/macbook/projects/project1/frontend-project-lvl1

Вижу, что владельцем является root

MacBook-Air-MacBook:node_modules macbook$ whoami
macbook

мой пользователь — macbook

ввожу sudo chown macbook /usr/local/lib/node_modules/frontend-project-lvl1_rain
И ничего не происходит. Не могу понять как поменять с root —> macbook


0

Сергей К.

Добрый день! Вы пробовали загуглить вопрос, как сменить пользователя файла или директории на вашей операционной системе? Каков результат?


0

Олег Рязанцев

chown -R  macbook:staff /путь 

Спасибо!


0

Alexey

Простите, а как понять какую группу пользователей нужно указывать? Я проверяю группу в которой есть мой пользователь — их много, я указываю первую, пробую без группы, устанавливаю рекурсивно владельца папки, которая указана в ошибке, устанавливаю права 755 — без толку, Permission denied.


0

Олег Рязанцев

Я, конечно, не претендую на истину, но могу ответить, как вижу я.
1 вариант (топорный): создать любую папку и тут же посмотреть какой группе она принадлежит(ls -lG). (по идее она должна быть под твоим пользователем и группой)
2 вариант. Набрать команду id. Сначала выйдет твое имя пользователя, а потом и группа, к которой пользователь принадлежит.
Выше в посте по идее написано решение проблемы, надо только свои данные туда подставить.


0

Alexey

Да я все так и делаю, не помогает. Я видимо не понимаю какие права на директорию нужно выставлять, потому что в разных вариантах разные ошибки доступа, то permission denied, unlink, то permission denied, open.


0

Alexey

А, вон оно что, я ставил права непосредственно на папку с проектом, а надо было на уровень повыше. По крайней мере мне это помогло.


1

Maxim Balyura

У меня тоже npm link ругался на отсутствие доступа к папкам /usr/local/lib/node_modules/ и /usr/local/bin/. Я с помощью sudo chown поменял у них владельца на себя (был root), и все заработало. Это правильное решение или я что-то накосячил на предыдущих шагах?


1

Олег Рязанцев

Maxim Balyura, я сделал точно так же.


0

user-ef37593a5e175f35

Скажите пожалуйста на каком сайте нашли инфу а то я что то не соображу?


0

user-ef37593a5e175f35

Я просто прописываю sudo chown в терминале и что то там меняю или как?


0

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»;

Понравилась статья? Поделить с друзьями:
  • 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