Npm EACCESS error when installing Firebase - node.js

I used to be able to run and deploy my code using firebase. I then upgraded to the new m1 MacBook pro. I git cloned my code and made some minor changes. I tried using
firebase deploy
but I got the error message
zsh: command not found: firebase
then I tried
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 har-validator#5.1.5: this library is no longer supported
npm WARN deprecated debug#4.1.0: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm ERR! code EACCES
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 -13
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/firebase-tools/lib/bin/firebase.js' -> '/usr/local/bin/firebase'
npm ERR! [OperationalError: EACCES: permission denied, symlink '../lib/node_modules/firebase-tools/lib/bin/firebase.js' -> '/usr/local/bin/firebase'] {
npm ERR! cause: [Error: EACCES: permission denied, symlink '../lib/node_modules/firebase-tools/lib/bin/firebase.js' -> '/usr/local/bin/firebase'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
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! },
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
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! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/brennanadams/.npm/_logs/2020-12-03T18_52_42_463Z-debug.log
I looked this up on the internet but I have yet to find a solution, any help is appreciated. I am not sure if this is because I have the m1 chip and it not compatible or if a bunch of my settings reset when I upgraded. Thank you for help.

To install an npm package globally on Mac, try running with the sudo command. You'll need to enter your password.
sudo npm install -g firebase-tools

EDIT: Original title for this question asked about the request deprecation which is why I spend a paragraph explaining that's not the real problem before getting to what the real issue is and what needs to be done.
Regarding request: You don't need to do anything about that. request will continue working just fine as a dependency of firebase. Hopefully, they will replace it with something else at some point, but there's no issue to address. The deprecation of the request module was done as a proactive measure to push people to more actively-maintained and modern solutions. It wasn't because there's something fundamentally broken with request that requires people to move to something else now now now or anything like that.
Instead, your problem here is the EACCESS issue. For that, you'll want to review the npm documentation on that problem. The upshot is you probably want to reinstall Node.js with a version manager such as nvm. If you can't or don't want to do that, you can configure npm to install global packages in a directory that you have write permission to.

It worked with Yarn, Try:
yarn global add firebase-tools
export PATH="$(yarn global bin):$PATH"
command -v firebase
and firebase login will work normally

Related

EACCES error every time I try and do something with npm

Whenever I do anything related to npm, including uninstalling npm itself, I get this error:
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/bin/corepack
npm ERR! dest /usr/local/bin/.corepack-0KY6b4OJ
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/bin/corepack' -> '/usr/local/bin/.corepack-0KY6b4OJ'
npm ERR! [Error: EACCES: permission denied, rename '/usr/local/bin/corepack' -> '/usr/local/bin/.corepack-0KY6b4OJ'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/local/bin/corepack',
npm ERR! dest: '/usr/local/bin/.corepack-0KY6b4OJ'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
This didn't use to be the case as I have had no issues in the past, although the last time I tried to use an npm-related command was about a year ago.
I've tried many solutions, including sudo, nvm and uninstalling Node completely but nothing seems to work. I haven't used Node much before so I'm not very familiar with it unfortunately, so any help would be greatly appreciated.
run npm package as administrator by using the command
sudo npm install -g npm#latest
Turns out it was an issue with my antivirus software! After disabling the software and installing NVM everything now works fine.

How to get npm or sass to install globally?

I've been watching tutorials and searching all over, and I've seen several similar issues on here. But none with the same errors. So I apologize if this has been answered before.
I'm taking a self-paced coding class. And I'm supposed to install sass. I finally found a tutorial that seemed straightforward. But when I entered the commands I'm getting error codes in my terminal. I'm very new to all this, so I have no idea what any of this means.
Some context: I downloaded homebrew, but didn't understand that either (so I uninstalled it). So then I Followed THIS tutorial where I downloaded node.js/npm. And everything went fine until I tried the install -g sass command. Then I started getting all these messages and going down the rabbit hole. Npmjs.com has some info on this issue, but I couldn't figure it out. It mentions reinstalling npm, or using "nvm". But when I tried the command npm install -g npm it returned very similar errors.
carlosprieto#Carloss-Mac-mini ~ % npm install -g sass
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/sass
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/sass'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/sass'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/sass'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/carlosprieto/.npm/_logs/2022-06-17T16_02_28_018Z-debug-0.log
you need admin access, using sudo should help you
sudo npm i -g sass
this means you have superuser access, and is required to install packages globally.
read more here: https://www.tutorialspoint.com/unix_commands/sudo.htm

npm ERR! Error: EACCES: permission denied

I'm having this famous issue while trying to install Typescript in my react app. Concretely, I am running this: npm install --save typescript #types/node #types/react #types/react-dom #types/jest
and I am getting this response:
npm ERR! code EACCES npm ERR! syscall rename npm ERR! path
/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/node npm ERR!
dest
/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/.node-8MzkXP42
npm ERR! errno -13 npm ERR! Error: EACCES: permission denied, rename
'/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/node' ->
'/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/.node-8MzkXP42'
npm ERR! [Error: EACCES: permission denied, rename
'/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/node' ->
'/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/.node-8MzkXP42']
{ npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR!
syscall: 'rename', npm ERR! path:
'/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/node', npm
ERR! dest:
'/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/.node-8MzkXP42'
npm ERR! } npm ERR! npm ERR! The operation was rejected by your
operating system. npm ERR! It is likely you do not have the
permissions to access this file as the current user npm ERR! npm ERR!
If you believe this might be a permissions issue, please double-check
the npm ERR! permissions of the file and its containing directories,
or try running npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in: npm ERR!
/home/asier/.npm/_logs/2021-04-29T10_48_16_436Z-debug.log
I've checked the ownership of that folder: ls -l/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/node, and I am the owner of all the files.
I've also tried to install it executing npm set unsafe-perm true
but didn't work.
I've installed npm and node with NVM and I am using Windows 10 with
Ubuntu on WSL.
npm -v: 7.11.1
node -v: v15.14.0
nvm --version: 0.34.0
The weird thing is that I can install other packages with no issues, I just installed react-hook-form for example.
I don't really know which can be the issue and I would be very happy if you guys can give me a clue!
Thank you beforehand for the help! :)
As I saw an error is related to permission. So you need to execute the command with the help of "sudo" like,
sudo npm install --save typescript #types/node #types/react #types/react-dom #types/jest
I had the same problem and the way to fix it was to stop my code that was running (webpack serve). In Windows you can't edit/delete files when those are in use. I think wsl may behave the same as it is a linux subsystem "inside" Windows.

Errors while installing AWS Amplify CLI

Tried installing the CLI with the command given on the official website, this is the response :
npm install -g #aws-amplify/cli
npm WARN deprecated #types/ora#3.2.0: This is a stub types definition. ora provides its own type definitions, so you do not need this installed.
npm WARN deprecated node-uuid#1.4.8: Use uuid module instead
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm WARN #conduitvc/mosca#2.8.3 requires a peer of leveldown#~1.4.3 but none is installed. You must install peer dependencies yourself.
npm WARN #conduitvc/mosca#2.8.3 requires a peer of ioredis#^1.15.1 but none is installed. You must install peer dependencies yourself.
npm WARN #conduitvc/mosca#2.8.3 requires a peer of mongodb#~2.1.4 but none is installed. You must install peer dependencies yourself.
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
I have installed the latest versions of node and npm. Fixing this would be really helpful. TIA
In my case, I just had to add sudo in front of my command line request on my Mac Command Line:
sudo npm install -g #aws-amplify/cli
I was having the same issue. What worked for me was:
npm uninstall -g #aws-amplify/cli
npm install -g #aws-amplify/cli
Make sure your PC is connected to internet connection during all of this. If possible don't minimize the window, wait until everything is properly installed.
Read a blogpost on this similar error and that author suggests to install typescript, which would fix the problem. Followed that advice, installed typescript and installed aws cli and voila! it worked!. No idea how, but it fixed my problem. Curious to know how, if anyone is aware of this please let me know in your answer. TIA
sudo chown -R $USER:$(id -gn $USER) /Users/user_name/.config

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
This worked for me:
sudo npm install -g firebase-tools
Apparently the installation requires superuser privileges, which you can request with sudo.
Try a variety of things:
Try repeatedly to uninstall and reinstall. Sometimes the problem can clear itself up.
npm uninstall -g firebase-tools; npm install -g firebase-tools
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?
Completely blow away the location where it's trying to install, which is apparently /Users/ahmadbazzi/.npm-global for you.
This worked for me, try:
npm i firebase --save --force

Resources