npm, global install failing, getting Error: EACCES: permission denied - javascript

So I'm logged in as administrator of my MacBook and want to run a npm command in my Django project. However, It refuses due to missing permissions.
(venv) jonas#Air-von-Jonas salaryx % npm install -g sass
npm ERR! code EACCES
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/sass/sass.js
npm ERR! dest /usr/local/bin/sass
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/sass/sass.js' -> '/usr/local/bin/sass'
npm ERR! [Error: EACCES: permission denied, symlink '../lib/node_modules/sass/sass.js' -> '/usr/local/bin/sass'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'symlink',
npm ERR! path: '../lib/node_modules/sass/sass.js',
npm ERR! dest: '/usr/local/bin/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/jonas/.npm/_logs/2022-03-24T06_04_35_362Z-debug.log
(venv) jonas#Air-von-Jonas salaryx %
Also it seems that I can't change permissions of a folder, I can unlock the lock on the bottom right but then once I try to change permission for "wheel" e.g. it refuses as well.

You are having a system permission issue. An easy way to avoid it is to use the sudo command:
sudo npm install -g sass
Otherwise you can visit Resolving EACCES permissions errors when installing packages globally from npm's official doc. There is a guide, and the solution is to either reinstall npm with a node version manager or manually change its default directory.

Related

How to install vanilla spa on mac?

I have been struggling to install Vanilla for JavaScript. According to the instructions I have to use the command npm install --global serve, when I do that, errors fill the screen saying I don't have permission etc.
Also I have tried using --location=global as they suggested.
Error messages are attached below:
Windows10#MacBook-Air ~ % npm install --global serve
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/serve
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/serve'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/serve'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/serve'
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/Windows10/.npm/_logs/2022-09-07T16_30_32_036Z-debug-0.log
Windows10#MacBook-Air ~ %

Failed to install "expo-cli" using "npm install -g expo-cli"

I am failed to install expo-cli using npm install -g expo-cli for android application creation.
NPM version: 7.19.1
Node version: v15.14.0
After using npm install -g expo-cli it's failed to install and the error is given below,
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/expo-cli
npm ERR! dest /usr/local/lib/node_modules/.expo-cli-dKBr48UN
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/expo-cli' -> '/usr/local/lib/node_modules/.expo-cli-dKBr48UN'
npm ERR! [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/expo-cli' -> '/usr/local/lib/node_modules/.expo-cli-dKBr48UN'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/local/lib/node_modules/expo-cli',
npm ERR! dest: '/usr/local/lib/node_modules/.expo-cli-dKBr48UN'
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/imdadul/.npm/_logs/2021-07-27T05_54_14_633Z-debug.log
I have tried to solve this issue and use the below command's: npm cache clean --force but it was not solved and that's why I have used sudo npm cache clean --force command because of using Ubuntu 20.04 operating system and again run npm install -g expo-cli command.
Note: I am failed every time and I need help to install expo-cli. Advanced thanks and please concern the attached file.
You have to try two methods:
First is to use the command with sudo npm install expo-cli (if you have not used sudo)
the Second is to delete node_modules and install run again npm install
Maybe it will work

Failed to install json-server on Ubuntu 20.04

I am trying to install json-server but failed repeatedly and it makes me hopeless. Now need help to makes the solution. Below the command which I have used on the Ubunto-20.04 Operating System.
Installed Nodejs version: v14.16.0
Installed NPM version: 6.14.10
And Although firstly, I used the latest version of nodejs which was 15x but I also faced an error to install json-server and below's command used to install json-server
npm install json-server -g
npm install -g json-server
npm i json-server
I have used all of the above command to install json-server but in every moments I faced error and that's given below,
Here is error
checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
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! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules'
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/imdadul/.npm/_logs/2021-03-18T04_32_41_181Z-debug.log
Note: The error also added in the attached file and Advanced thanks for your helps.
You could try with sudo like "sudo npm install -g json-server" or give write permission with "chmod -r 777 /usr/local/lib/node_modules". I think that sudo option is better for instant permisson.
You're running the command with the right permissions, you should chmod the node_modules and run the command again with sudo.

Problem installing nodemon globally on macOS Mojave

In the Visual Studio Code terminal I issue to following command:
npm install -g nodemon
The result in terminal is:
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
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! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules'
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/ilkin/.npm/_logs/2020-08-30T16_39_29_236Z-debug.log
How can I solve it?
Use sudo before installing, it will ask for credentials enter it and done
sudo npm i - g nodemon
This means that you do not have root privileges / are not a superuser. You have two ways to solve this.
Use sudo before the command - this will usually then ask for credentials and run the command without a problem (hopefully)
Run sudo -s to automatically run commands with sudo every time in the current terminal window (will deactivate once the terminal has been closed)
Run sudo su which will make the computer think that the current terminal window has been opened by a root user (again will deactivate once current window has been closed)

Unable to install create-react-app with npm

Relatively new to programming and currently trying to install create-react-app with npm and its giving me this output:
jacobb$ npm install -g create-react-app
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
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: "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!
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/jacobb/.npm/_logs/2019-12-04T22_00_50_323Z-debug.log
I've checked permissions and the folder is able to be accessed by everyone, so I don't think that's the issue. I looked up other questions related to this on the site and I wasn't sure if they were the same since everyone else's output seemed to be different. Apologies if this is the same as another question I've missed.

Categories