Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: EACCES, permission denied even after using sudo?

I am trying to set up a chrome extension that will automatically save the changes I make to my website with the inspect element feature. The idea is that you'll be able to make real time changes to the website without having to go back into the ide to save the changes and re-upload and everything. The extension is called DevTools Autosave. I've been following the instructions from this site. I'm trying to install this on a mac.

I've installed node.js and the extension already. When I got to the part in the instructions where it talks about which commands to run in the terminal I've tried both with and without the "sudo" in front of the "npm install -g autosave" command but I always get this error:

Error: EACCES, permission denied
    at Function.startup.resolveArgv0 (node.js:815:23)
    at startup (node.js:58:13)
    at node.js:906:3

npm ERR! [email protected] install: `node ./scripts/install.js`
npm ERR! Exit status 8
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the autosave package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ./scripts/install.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls autosave
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 14.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "autosave"
npm ERR! cwd /Users/Brent
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0

Anyone know how I can fix this? I can't find anyone that is having this problem and I've been on a few different forums now but can't find a solution. Thanks in advance.

like image 884
Digital Brent Avatar asked Dec 14 '14 23:12

Digital Brent


People also ask

What might be causing the error error Eacces Permission denied access '/ usr local lib Node_modules '?

This means you do not have permission to write to the directories npm uses to store global packages and commands. Try running commands: sudo chmod u+x -R 775 ~/. npm and sudo chown $USER -R ~/. npm or you can just run any npm command with sudo , that should get resolve your issue.

What does Eacces mean?

EACCES is almost always used when the system call was passed a path that was inaccessible by the current user. EPERM is used in various other situations where you need to be root to perform an action, e.g. kill() on a process that you don't own. link() on a directory.


2 Answers

You have two options: Either fix your npm setup, so you can use npm -g, or install autosave locally.

To install locally (i.e. in node_modules within your current directory), run npm install autosave (without -g). Then you can run ./node_modules/.bin/autosave or ./node_modules/autosave/bin/autosave to start autosave.

To fix your npm setup, so you can use -g without root permissions (recommended):

In your home dir (assuming /Users/Brent/), create a file called .npmrc with the following content:

cache = /Users/Brent/.npm/cache
globalconfig = /Users/Brent/.npm/npmrc
globalignorefile = /Users/Brent/.npm/npmignore
prefix = /Users/Brent/.npm

And add ~/.npm/lib/node_modules to your NODE_PATH, e.g. by putting the following in .bashrc (assuming that your shell is bash) to allow the modules to be found, and append ~/.npm/bintoPATHso you can run any installed binary (i.e. runautosave` from anywhere):

export NODE_PATH=$HOME/.npm/lib/node_modules
export PATH=$PATH:$HOME/.npm/bin

(changes to .bashrc only take effect when you load the shell, or use . ~/.bashrc; if you want to use the new setup without reloading the shell, just run that line (export ...) in your current shell).

like image 169
Rob W Avatar answered Oct 10 '22 04:10

Rob W


As of 2020, here is the recommended solution by npm. It worked for me (OSX). (No need to change any path configuration or .bashrc)

Steps:

  1. Install nvm by running below command.

If you are using bash

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash

If you are using zsh

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | zsh
  1. Install node using nvm (No need to uninstall existing node/npm)

nvm install 12.13.1

like image 36
Balamurugan N Avatar answered Oct 10 '22 02:10

Balamurugan N