我正在我的新MacBook Air M1上为一个新项目安装Firebase Tools,在运行sudo 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 uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm ERR! code EEXIST
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 -17
npm ERR! EEXIST: file already exists, symlink '../lib/node_modules/firebase-tools/lib/bin/firebase.js' -> '/usr/local/bin/firebase'
npm ERR! File exists: /usr/local/bin/firebase
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
我在谷歌上搜索了很多,没有线索...
还尝试了使用错误消息建议的--force安装npm clean cache
、npm clean cache --force
和npm:npm install -g --force firebase-tools
npm WARN using --force I sure hope you know what you are doing.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm ERR! code EEXIST
npm ERR! path /usr/local/bin/firebase
npm ERR! Refusing to delete /usr/local/bin/firebase: node_modules/npm/bin/npm-cli.js symlink target is not controlled by npm /usr/local/bin
npm ERR! File exists: /usr/local/bin/firebase
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
更新:我终于知道如何在mac上找到隐藏文件,并删除了有问题的文件,现在我得到了这个错误:
sudo 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 uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
/usr/local/bin/firebase -> /usr/local/lib/node_modules/firebase-tools/lib/bin/firebase.js
> re2@1.16.0 install /usr/local/lib/node_modules/firebase-tools/node_modules/re2
> install-from-cache --artifact build/Release/re2.node --host-var RE2_DOWNLOAD_MIRROR || npm run rebuild
Trying https://github.com/uhop/node-re2/releases/download/1.16.0/darwin-x64-83.br ...
Writing to build/Release/re2.node ...
Trying https://github.com/uhop/node-re2/releases/download/1.16.0/darwin-x64-83.gz ...
Writing to build/Release/re2.node ...
Building locally ...
> re2@1.16.0 rebuild /usr/local/lib/node_modules/firebase-tools/node_modules/re2
> node-gyp rebuild
gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/Users/macshac/Library/Caches/node-gyp/14.17.1"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/firebase-tools/node_modules/re2/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/firebase-tools/node_modules/re2/.node-gyp'
gyp ERR! System Darwin 20.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/firebase-tools/node_modules/re2
gyp ERR! node -v v14.17.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! re2@1.16.0 rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the re2@1.16.0 rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
(node:11071) UnhandledPromiseRejectionWarning: 1
(Use `node --trace-warnings ...` to show where the warning was created)
(node:11071) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:11071) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
> protobufjs@6.11.2 postinstall /usr/local/lib/node_modules/firebase-tools/node_modules/protobufjs
> node scripts/postinstall
+ firebase-tools@9.16.0
added 694 packages from 431 contributors in 32.015s
(It没有sudo
也无法工作)
4条答案
按热度按时间xbp102n01#
我终于能够删除有问题的现有文件(firebase.js),通过使用
Command + Shift + G
搜索隐藏文件路径/usr/local/bin
,然后我得到了问题更新中显示的第二组错误。此时我意识到我在一个已经有firebase项目的目录中,并将目录更改为新项目,再次运行sudo npm install -g firebase-tools
,它工作了。我仍然有点困惑,但最终我认为是什么做了它删除了违规文件。虽然我仍然不知道为什么我在目录重要,因为它是一个全局安装...
bfrts1fy2#
为了最小化权限错误的可能性,您可以配置npm使用不同的目录。在本例中,您将在主目录中创建并使用隐藏目录。
1-备份您的计算机。
2-在命令行的主目录中,创建全局安装目录:
mkdir~/. npm-全局
3-配置npm以使用新目录路径:
npm配置设置前缀'~/. npm-global '
4-在您喜欢的文本编辑器中,打开或创建一个~/. profile文件并添加以下行:
导出路径=~/. npm-全局/bin:$路径
5-在命令行上,更新系统变量:
源文件~/. profile
6-要测试新配置,请在不使用sudo的情况下全局安装程序包:
npm install-g jshint代替步骤2 - 4,你可以使用相应的ENV变量(例如,如果你不想修改~/. profile):
NPM配置前缀=~/. npm-全局
isr3a4wc3#
我卸载了自制程序,它似乎解决了这个问题。
然后运行
npm audit fix
i1icjdpr4#
使用sudo运行命令:尝试在命令前面加上"sudo"再次运行该命令,如下所示:sudo npm install-g firebase-tools.这将以管理员权限运行该命令,这将授予它创建目录所需的权限。