当我尝试通过以下方式安装firebase-tools
时:
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 deprecated mkdirp@0.5.4: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
/usr/local/bin/firebase -> /usr/local/lib/node_modules/firebase-tools/lib/bin/firebase.js
npm WARN lifecycle The node binary used for scripts is /snap/bin/node but npm is using /snap/node/2609/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
> protobufjs@6.8.9 postinstall /usr/local/lib/node_modules/firebase-tools/node_modules/protobufjs
> node scripts/postinstall
2020/03/31 16:23:53.220338 cmd_run.go:884: WARNING: cannot create user data directory: cannot create "/nonexistent/snap/node/2609": mkdir /nonexistent: permission denied
cannot create user data directory: /nonexistent/snap/node/2609: Permission denied
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! code ELIFECYCLE
npm ERR! errno 1
npm ERR! protobufjs@6.8.9 postinstall: `node scripts/postinstall`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the protobufjs@6.8.9 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/david/.npm/_logs/2020-03-31T21_23_53_670Z-debug.log
我已经用Google搜索了此错误,但没有发现任何相关信息。我该怎么做才能安装firebase-tools
?
答案 0 :(得分:0)
我遇到了同样的问题,但是我没有在全球范围内安装它来解决它
尝试一下 npm install firebase-tools
或
sudo npm install -g firebase-tools
答案 1 :(得分:0)
原因:您使用 snap 来安装 node,而 snap 不允许应用写入 /usr/local
,而所有全局包都安装在这里。
你能做些什么来解决这个问题?
snap remove node
- 卸载 node 的 snap 版本sudo apt-get install nodejs
- 安装 nodejsnpm install -g firebase-tools
- 现在应该可以使用了