Upgrading npm, npm ERR! Error: EACCES: permission denied - npm

Command: npm install -g npm#latest
Result:
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/.staging/npm-3e479054/node_modules/string-width
npm ERR! dest /usr/local/lib/node_modules/.staging/string-width-fa87d55b
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/.staging/npm-3e479054/node_modules/string-width' -> '/usr/local/lib/node_modules/.staging/string-width-fa87d55b'
npm ERR! [OperationalError: EACCES: permission denied, rename '/usr/local/lib/node_modules/.staging/npm-3e479054/node_modules/string-width' -> '/usr/local/lib/node_modules/.staging/string-width-fa87d55b'] {
npm ERR! cause: [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/.staging/npm-3e479054/node_modules/string-width' -> '/usr/local/lib/node_modules/.staging/string-width-fa87d55b'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/local/lib/node_modules/.staging/npm-3e479054/node_modules/string-width',
npm ERR! dest: '/usr/local/lib/node_modules/.staging/string-width-fa87d55b'
npm ERR! },
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/local/lib/node_modules/.staging/npm-3e479054/node_modules/string-width',
npm ERR! dest: '/usr/local/lib/node_modules/.staging/string-width-fa87d55b'
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/surendra/.npm/_logs/2021-05-06T12_41_30_866Z-debug.log

Run NPM package as administrator by using sudo
sudo npm install -g npm#latest

Related

Error message setting up Browser Stack with cypress: Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/browserstack-cypress-cli'

I am trying to install browserStac using he following command:
npm install -g browserstack-cypress-cli
I Got the following error message:
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/browserstack-cypress-cli
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/browserstack-cypress-cli'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/browserstack-cypress-cli'] {
➜ RHS.Website.Automation git:(regression)
npm install -g browserstack-cypress-cli
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/browserstack-cypress-cli
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/browserstack-cypress-cli'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/browserstack-cypress-cli'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/browserstack-cypress-cli'
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/jacquelinegeorge/.npm/_logs/2022-12-13T12_31_56_083Z-debug-0.log
➜ RHS.Website.Automation git:(regression)
I'm honestly very confused right because this should this framework is new and I've attempted to install cypress before.
What is wrong exactly and and how do I fix it.
Seems like a permission issue.
You should be using:
sudo npm install -g browserstack-cypress-cli

I'm trying to download Sanity for this particular project but for some reason on the terminal it's showing this

I'm trying to install Sanity for this project but I'm having trouble installing it and it shows this.
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/#sanity
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/#sanity'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/#sanity'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/#sanity'
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/****/.npm/_logs/2022-08-03T22_03_07_802Z-debug-0.log
zsh: command not found: sanity

Can't install json-server

I am trying to install JSON-Server, but it's not working!
I have used the following command: npm install -g json-server
Here is the error message:
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/json-server
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/json-server'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/json-server'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/json-server'
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.
Try to use sudo before command :
sudo npm install -g json-server

npm install is not working npm ERR! code EPERM npm ERR! syscall mkdir npm ERR! path C:\Users\avtar~saini npm ERR! errno -4048

G:\angularProject\battingApp-update>npm i
npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path C:\Users\avtar~saini
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'C:\Users\avtar~saini'
npm ERR! [OperationalError: EPERM: operation not permitted, mkdir 'C:\Users\avtar~saini'] {
npm ERR! cause: [Error: EPERM: operation not permitted, mkdir 'C:\Users\avtar~saini'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'mkdir',
npm ERR! path: 'C:\\Users\\avtar~saini'
npm ERR! },
npm ERR! isOperational: true,
npm ERR! stack: "Error: EPERM: operation not permitted, mkdir 'C:\\Users\\avtar~saini'",
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'mkdir',
npm ERR! path: 'C:\\Users\\avtar~saini'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
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.
Looks like some permission issues.
First thing which you can do is run this command with administrative permissions.
If that doesn't work then You can try this with administrative permissions:
npm i --unsafe-perms
I think these should solve your problem

Can't upgrade npm from "npm install -g npm#latest" command

$ npm install -g npm#latest
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js\
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js\
npm ERR! code EACCES\
npm ERR! syscall mkdir\
npm ERR! path /usr/local/share/man/man1\
npm ERR! errno -13\
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/share/man/man1'\
npm ERR! { [Error: EACCES: permission denied, mkdir '/usr/local/share/man/man1']\
npm ERR! cause:\
npm ERR! { Error: EACCES: permission denied, mkdir '/usr/local/share/man/man1'\
npm ERR! errno: -13,\
npm ERR! code: 'EACCES',\
npm ERR! syscall: 'mkdir',\
npm ERR! path: '/usr/local/share/man/man1' },\
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, mkdir \'/usr/local/share/man/man1\'',\
npm ERR! errno: -13,\
npm ERR! code: 'EACCES',\
npm ERR! syscall: 'mkdir',\
npm ERR! path: '/usr/local/share/man/man1' }\
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/katha/.npm/_logs/2021-05-13T12_20_16_050Z-debug.log