NPM Throws a EACCES error

I am getting an EACCES error when running npm install -g firebase-tools, my package.json:

{
  "name": "ZiA-Chat",
  "version": "0.0.1",
  "description": "In-development Chat App",
  "main": "server.js",
  "scripts": {
    "start": "node server.js"
  },
  "dependencies": {
    "express": "^4.17.1",
    "socket.io": "^2.3.0",
    "firebase": "^7.9.2"
  },
  "engines": {
    "node": "12.x"
  },
  "license": "MIT"
}

The console:

app@zia:~ 22:29 
$ npm install -g firebase-tools
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN checkPermissions Missing write access to /opt/nvm/versions/node/v12.0.0/lib/node_modules
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/firebase-tools/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! path /opt/nvm/versions/node/v12.0.0/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/opt/nvm/versions/node/v12.0.0/lib/node_modules'
npm ERR!  [Error: EACCES: permission denied, access '/opt/nvm/versions/node/v12.0.0/lib/node_modules'] {
npm ERR!   stack: 'Error: EACCES: permission denied, access ' +
npm ERR!     "'/opt/nvm/versions/node/v12.0.0/lib/node_modules'",
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/opt/nvm/versions/node/v12.0.0/lib/node_modules'
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 (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npm-cache/12.0.0/_logs/2020-02-29T22_30_19_022Z-debug.log

I do not know the reason for this, and am new to using firebase, any help would be appreciated!

npm install -g instructs npm to install a package globally, meaning for everybody’s project, which is beyond your level of access :slight_smile:

Try it without the -g option

Problem is, I need to have it globally, so I can use it from the command line, otherwise, it’s worthless

Don’t worry! Someone will know a workaround.

Have you tried the graphical installer in your package.json file? That may install globally

Instal firebase-tools with npm i firebase-tools

Then execute the following command to make an alias to start the firebase-tools CLI:

alias firebase='node /app/node_modules/firebase-tools/lib/cli.js'

You will need to run that command on every new console session

You can then start/access the CLI with the command firebase

e.g firebase --help

Actually, if you add that line to a .bashrc file then it would save the headache

1 Like

Nice idea, but the console doesn’t seem to be sourcing .bashrc

If it does not show up in your console, type ls -a to show all files that may be hidden. Then using vim or nano edit the file

1 Like