我首先安装了节点和npm
Ahmads-MacBook-Pro:~ ahmadbazzi$ npm --version
5.6.0
Ahmads-MacBook-Pro:~ ahmadbazzi$ node --version
v8.9.4
然后,我按照此处https://firebase.google.com/docs/functions/get-started的步骤去安装firebase CLI。我先执行
Ahmads-MacBook-Pro:~ ahmadbazzi$ npm install -g firebase-tools
给了我很多警告
npm WARN deprecated [email protected]: 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/[email protected] (node_modules/firebase-tools/node_modules/@google-cloud/functions-emulator):
npm WARN 404 SKIPPING OPTIONAL DEPENDENCY: Not Found: @google-cloud/[email protected]
以及一大堆错误
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
尝试各种方法:
反复尝试卸载并重新安装。有时问题可以解决。
npm uninstall -g firebase-tools; npm install -g firebase-tools
检查错误消息中文件的特定权限。您对它们有写权限吗?如果不这样做,是否可能需要使用sudo
来编写它们?
完全吹走它要安装的位置,对您来说显然是/Users/ahmadbazzi/.npm-global
。
这对我有用:
sudo npm install -g firebase-tools
显然,安装需要超级用户特权,您可以使用sudo
来请求。
可能有点晚,但这对我有用-即使我(反复)在全球范围内安装了该软件包,我的bash也无法识别该命令。因此,请完成
中的所有步骤https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
此后它就像一种魅力!