简体   繁体   中英

Can not install Firebase CLI using npm

I first installed node and npm

Ahmads-MacBook-Pro:~ ahmadbazzi$ npm --version
5.6.0
Ahmads-MacBook-Pro:~ ahmadbazzi$ node --version
v8.9.4

Then i went to install the firebase CLI following the steps here https://firebase.google.com/docs/functions/get-started . I first executed

Ahmads-MacBook-Pro:~ ahmadbazzi$ npm install -g firebase-tools

which gave me a whole bunch of warnings

npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN checkPermissions Missing write access to /Users/ahmadbazzi/.npm-global/lib/node_modules/firebase-tools
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @google-cloud/functions-emulator@1.0.0-alpha.23 (node_modules/firebase-tools/node_modules/@google-cloud/functions-emulator):
npm WARN 404 SKIPPING OPTIONAL DEPENDENCY: Not Found: @google-cloud/functions-emulator@1.0.0-alpha.23

and a whole bunch of errors

npm ERR! path /Users/ahmadbazzi/.npm-global/lib/node_modules/firebase-tools
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/Users/ahmadbazzi/.npm-global/lib/node_modules/firebase-tools'
npm ERR!  { Error: EACCES: permission denied, access '/Users/ahmadbazzi/.npm-global/lib/node_modules/firebase-tools'
npm ERR!   stack: 'Error: EACCES: permission denied, access \'/Users/ahmadbazzi/.npm-global/lib/node_modules/firebase-tools\'',
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/Users/ahmadbazzi/.npm-global/lib/node_modules/firebase-tools' }`
npm ERR! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/ahmadbazzi/path to npmrc folder/_logs/2018-01-23T17_29_19_771Z-debug.log

Try a variety of things:

  1. Try repeatedly to uninstall and reinstall. Sometimes the problem can clear itself up.

    npm uninstall -g firebase-tools; npm install -g firebase-tools

  2. Check the specific permissions on the files in the error message. Do you have write access to them? If you don't, do you perhaps need to use sudo to write them?

  3. Completely blow away the location where it's trying to install, which is apparently /Users/ahmadbazzi/.npm-global for you.

This worked for me:

sudo npm install -g firebase-tools

Apparently the installation requires superuser privileges, which you can request with sudo .

Probably a tad too late, but here is what worked for me- Even though I'd (repeatedly) installed the package globally, my bash didn't recognise the command. So working through all the steps in

https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

and it worked like a charm after that!

This worked for me Try: npm i firebase --save --force

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM