Npm EACCESS error when installing Firebase

2.3k Views Asked by At

I used to be able to run and deploy my code using firebase. I then upgraded to the new m1 MacBook pro. I git cloned my code and made some minor changes. I tried using

firebase deploy

but I got the error message

zsh: command not found: firebase

then I tried

npm install -g firebase-tools
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm ERR! code EACCES
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/firebase-tools/lib/bin/firebase.js
npm ERR! dest /usr/local/bin/firebase
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/firebase-tools/lib/bin/firebase.js' -> '/usr/local/bin/firebase'
npm ERR!  [OperationalError: EACCES: permission denied, symlink '../lib/node_modules/firebase-tools/lib/bin/firebase.js' -> '/usr/local/bin/firebase'] {
npm ERR!   cause: [Error: EACCES: permission denied, symlink '../lib/node_modules/firebase-tools/lib/bin/firebase.js' -> '/usr/local/bin/firebase'] {
npm ERR!     errno: -13,
npm ERR!     code: 'EACCES',
npm ERR!     syscall: 'symlink',
npm ERR!     path: '../lib/node_modules/firebase-tools/lib/bin/firebase.js',
npm ERR!     dest: '/usr/local/bin/firebase'
npm ERR!   },
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'symlink',
npm ERR!   path: '../lib/node_modules/firebase-tools/lib/bin/firebase.js',
npm ERR!   dest: '/usr/local/bin/firebase'
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.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/brennanadams/.npm/_logs/2020-12-03T18_52_42_463Z-debug.log

I looked this up on the internet but I have yet to find a solution, any help is appreciated. I am not sure if this is because I have the m1 chip and it not compatible or if a bunch of my settings reset when I upgraded. Thank you for help.

4

There are 4 best solutions below

0
On

EDIT: Original title for this question asked about the request deprecation which is why I spend a paragraph explaining that's not the real problem before getting to what the real issue is and what needs to be done.

Regarding request: You don't need to do anything about that. request will continue working just fine as a dependency of firebase. Hopefully, they will replace it with something else at some point, but there's no issue to address. The deprecation of the request module was done as a proactive measure to push people to more actively-maintained and modern solutions. It wasn't because there's something fundamentally broken with request that requires people to move to something else now now now or anything like that.

Instead, your problem here is the EACCESS issue. For that, you'll want to review the npm documentation on that problem. The upshot is you probably want to reinstall Node.js with a version manager such as nvm. If you can't or don't want to do that, you can configure npm to install global packages in a directory that you have write permission to.

0
On

To install an npm package globally on Mac, try running with the sudo command. You'll need to enter your password.

sudo npm install -g firebase-tools

0
On

It worked with Yarn, Try:

yarn global add firebase-tools
export PATH="$(yarn global bin):$PATH"
command -v firebase

and firebase login will work normally

0
On

First go to the home directory.

mkdir ~/.npm-global

npm config set prefix '~/.npm-global'

In your preferred text editor, open or create a ~/.profile file and add this line:

export PATH=~/.npm-global/bin:$PATH

On the command line, update your system variables:

source ~/.profile

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

npm install -g firebase-tools