问题
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! autosave@1.0.3 install: `node ./scripts/install.js`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the autosave@1.0.3 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.
回答1:
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/binto
PATHso you can run any installed binary (i.e. run
autosave` 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).
来源:https://stackoverflow.com/questions/27475480/error-eacces-permission-denied-even-after-using-sudo