最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - npm ERR! when installing Firebase Tools (errno -17, EEXIST: file already exists, symlink) - Stack Overflow

programmeradmin0浏览0评论

I'm installing Firebase Tools for a new project on my new Macbook Air M1 and am running into the following issue on running the mand sudo npm install -g firebase-tools

npm WARN deprecated [email protected]: request has been deprecated, see 
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See /blog/math-random for details.
npm WARN deprecated [email protected]: 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.

I have googled a lot and have no leads...

Also tried npm clean cache, npm clean cache --force and npm install with --force as remended by the error message:

npm install -g --force firebase-tools

npm WARN using --force I sure hope you know what you are doing.
npm WARN deprecated [email protected]: request has been deprecated, see 
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See /blog/math-random for details.
npm WARN deprecated [email protected]: 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.

Update: I've finally figured out how to find hidden files on a mac and deleted the offending file. I now get this error:

sudo npm install -g firebase-tools
npm WARN deprecated [email protected]: request has been deprecated, see 
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See /blog/math-random for details.
npm WARN deprecated [email protected]: this library is no longer supported
/usr/local/bin/firebase -> /usr/local/lib/node_modules/firebase-tools/lib/bin/firebase.js

> [email protected] 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 .16.0/darwin-x64-83.br ...
Writing to build/Release/re2.node ...
Trying .16.0/darwin-x64-83.gz ...
Writing to build/Release/re2.node ...
Building locally ...

> [email protected] 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! mand "/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! [email protected] rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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 .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.

> [email protected] postinstall /usr/local/lib/node_modules/firebase-tools/node_modules/protobufjs
> node scripts/postinstall

+ [email protected]
added 694 packages from 431 contributors in 32.015s

(It also doesn't work without sudo)

I'm installing Firebase Tools for a new project on my new Macbook Air M1 and am running into the following issue on running the mand sudo npm install -g firebase-tools

npm WARN deprecated [email protected]: request has been deprecated, see https://github./request/request/issues/3142
npm WARN deprecated [email protected]: 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 [email protected]: 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.

I have googled a lot and have no leads...

Also tried npm clean cache, npm clean cache --force and npm install with --force as remended by the error message:

npm install -g --force firebase-tools

npm WARN using --force I sure hope you know what you are doing.
npm WARN deprecated [email protected]: request has been deprecated, see https://github./request/request/issues/3142
npm WARN deprecated [email protected]: 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 [email protected]: 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.

Update: I've finally figured out how to find hidden files on a mac and deleted the offending file. I now get this error:

sudo npm install -g firebase-tools
npm WARN deprecated [email protected]: request has been deprecated, see https://github./request/request/issues/3142
npm WARN deprecated [email protected]: 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 [email protected]: this library is no longer supported
/usr/local/bin/firebase -> /usr/local/lib/node_modules/firebase-tools/lib/bin/firebase.js

> [email protected] 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./uhop/node-re2/releases/download/1.16.0/darwin-x64-83.br ...
Writing to build/Release/re2.node ...
Trying https://github./uhop/node-re2/releases/download/1.16.0/darwin-x64-83.gz ...
Writing to build/Release/re2.node ...
Building locally ...

> [email protected] 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! mand "/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! [email protected] rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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/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.

> [email protected] postinstall /usr/local/lib/node_modules/firebase-tools/node_modules/protobufjs
> node scripts/postinstall

+ [email protected]
added 694 packages from 431 contributors in 32.015s

(It also doesn't work without sudo)

Share Improve this question edited Jul 21, 2021 at 1:15 Jeremy Irons asked Jul 20, 2021 at 3:03 Jeremy IronsJeremy Irons 5346 silver badges17 bronze badges 2
  • Seems like this question has been asked before Several Times and it appears it's just a warning. Do any of those posts help? – Jay Commented Jul 20, 2021 at 17:15
  • Would love if you found a solution for me, please link to it! I see similar questions but none with same errorno -17 or any helpful solutions... – Jeremy Irons Commented Jul 21, 2021 at 0:44
Add a ment  | 

5 Answers 5

Reset to default 4

Run the mand with sudo: Try running the mand again with 'sudo' in front of it, like this: sudo npm install -g firebase-tools. This will run the mand with administrator privileges, which should give it the necessary permissions to create the directory.

I was finally able to delete the offending existing file (firebase.js) by using Command + Shift + G to search the hidden file path /usr/local/bin I then got the second set of errors shown in the question update. I realized at this point I was in a directory where I already had a firebase project and changed directory to the new project and ran sudo npm install -g firebase-tools again and it worked.

I'm still a little confused, but ultimately I think what did it was deleting the offending file. Though I'm still not sure why the directory I was in mattered as it was a global install...

I solved it just by using --force to overwrite existing files with sudo.

sudo npm install -g firebase-tools --force

To minimize the chance of permissions errors, you can configure npm to use a different directory. In this example, you will create and use hidden directory in your home directory.

1-Back up your puter.

2-On the mand line, in your home directory, create a directory for global installations:

mkdir ~/.npm-global

3-Configure npm to use the new directory path:

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

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

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

5-On the mand line, update your system variables:

source ~/.profile

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

npm install -g jshint Instead of steps 2-4, you can use the corresponding ENV variable (e.g. if you don't want to modify ~/.profile):

NPM_CONFIG_PREFIX=~/.npm-global

I uninstalled homebrew and it seemed to fix the issue.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent./Homebrew/install/master/uninstall.sh)"

then ran npm audit fix

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论