11

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.

Digital Brent
  • 1,275
  • 7
  • 19
  • 47

2 Answers2

19

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).

Rob W
  • 341,306
  • 83
  • 791
  • 678
  • Thanks a lot! I had some trouble with the recommended method but the first one you gave me got it to work fine! – Digital Brent Dec 15 '14 at 17:43
  • @DigitalBrent What went wrong with the second method? If there is a mistake in my instructions, I'll happily correct it, because the recommended method is better because you can then use `autosave` from any directory. – Rob W Dec 15 '14 at 17:45
  • Not sure, I don't think the problem was with your instructions. They seemed pretty clear, but I still couldn't run autosave after I updated the file so I just tried the first method and that worked. Most likely it's my own ineptitude that caused the problem. – Digital Brent Dec 15 '14 at 22:01
  • @DigitalBrent Add `~/.npm/bin` to your PATH if you want to get `autosave` to work. – Rob W Dec 15 '14 at 22:06
3

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