When I try to install nodemon i get this error message - node.js

npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/nodemon
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir'/usr/local/lib/node_modules/nodemon'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/nodemon'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/nodemon'
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:
Looks like the problem is with the package generator-karma, not sure if this is the problem or not.
Can anyone show me what i need to do to get this installing correctly.
Thanks
Sanil

I believe you're trying to install a global package on your system by using npm install -g nodemon, then got permission denied, which is shown in error message.
You can't install a global package without root permission. If you want to do so, just execute it with root permission, like using sudo: sudo npm i -g nodemon or switch to root then execute again.

This looks like a permissions issue in your home directory. To reclaim ownership of the node_modules directory execute:
sudo chown -R $(whoami) ~/node_modules

Node.js error EACCES means you don't have access to the path it's specifying. In this case, /usr/local/lib/... is owned by the root user. See the command output here:
$ ls -l /usr/local/lib
total 12
drwxr-xr-x 4 root root 4096 Apr 7 23:45 node_modules
Nobody but root is allowed to write to the node_modules folder. This can be solved by prefixing your npm command with sudo to run the command as root.
See other: Understanding Linux File Permissions - Linuxize

Related

What should be done to have permits to join two modules of a project without using sudo?

I am trying to link two modules created by me, in a project created with Node.js, and as always I did: npm link . inside the module that I want to call, and from the other call it in package.json, and it gives me the following error:
npm ERR! path /home/miguel/cursos/cursoJs-Node/proyectoMichaelgram/michaelgram-db
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall symlink
npm ERR! Error: EACCES: permission denied, symlink '/home/miguel/cursos/cursoJs-Node/proyectoMichaelgram/michaelgram-db' -> '/usr/lib/node_modules/michaelgram-db'
npm ERR! { Error: EACCES: permission denied, symlink '/home/miguel/cursos/cursoJs-Node/proyectoMichaelgram/michaelgram-db' -> '/usr/lib/node_modules/michaelgram-db'
npm ERR! stack: 'Error: EACCES: permission denied, symlink \'/home/miguel/cursos/cursoJs-Node/proyectoMichaelgram/michaelgram-db\' -> \'/usr/lib/node_modules/michaelgram-db\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'symlink',
npm ERR! path: '/home/miguel/cursos/cursoJs-Node/proyectoMichaelgram/michaelgram-db',
npm ERR! dest: '/usr/lib/node_modules/michaelgram-db' }
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).
npm ERR! A complete log of this run can be found in:
npm ERR! /home/miguel/.npm/_logs/2018-07-17T12_02_46_081Z-debug.log
How should I install Node globally?
I have seen those files and they are owned by root. I put a new version of Ubuntu 18.04 I installed node Could it be problem when installing node? I do not remember how I did it, but on previous occasions I did not have this permission problem. I do not know if I should uninstall node and npm I have to install it in a way that I can access from any project I do. I already gave another file problems and I corregi using sudo, but it does not seem like a practice, because it should not give problems, never gave them node. What do you advise me to do to correct the problem and access node_modules without using sudo? Maybe I should uninstall and install it in another way? Thank you, I hope you understand my need, forgive the syntax but I must use the translator. Thank you.
I would advice you the 2 definitive ways given in the npm documenation
1)Reinstall npm with a version manager (recommended)
2)Change npm's default directory manually.
please visit https://docs.npmjs.com/getting-started/fixing-npm-permissions

npm ERR! code EACCESS by installing #angular/cli

Environment:
Ubuntu 16.04
node v8.11.1 (installed with package manager)
npm v5.6.0
After the clean installation of npm and trying to install #angular/cli
npm install -g #angular/cli
I'm getting an error related with EACCESS that it is probably related with permissions because it disappears with root access. The thing is that it is not recommended to use it that way, so how could I solve this?
Console ERROR
$ npm install -g #angular/cli
npm WARN checkPermissions Missing write access to /usr/lib/node_modules
npm ERR! path /usr/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR! { Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR! stack: 'Error: EACCES: permission denied, access \'/usr/lib/node_modules\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/lib/node_modules' }
npm ERR!
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! /home/user/.npm/_logs/2018-04-25T15_23_36_781Z-debug.log
File .npm/_logs/2018-04-25T15_23_36_781Z-debug.log
2566 warn checkPermissions Missing write access to /usr/lib/node_modules
2567 verbose stack Error: EACCES: permission denied, access '/usr/lib/node_modules'
2568 verbose cwd /opt/workspace/roscam-front
2569 verbose Linux 2.6.32-042stab120.19
2570 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "#angular/cli"
2571 verbose node v8.11.1
2572 verbose npm v5.6.0
2573 error path /usr/lib/node_modules
2574 error code EACCES
2575 error errno -13
2576 error syscall access
2577 error Error: EACCES: permission denied, access '/usr/lib/node_modules'
2577 error { Error: EACCES: permission denied, access '/usr/lib/node_modules'
2577 error stack: 'Error: EACCES: permission denied, access \'/usr/lib/node_modules\'',
2577 error errno: -13,
2577 error code: 'EACCES',
2577 error syscall: 'access',
2577 error path: '/usr/lib/node_modules' }
2578 error Please try running this command again as root/Administrator.
2579 verbose exit [ -13, true ]
One option to deal with this problem will be to change npm's default directory to use a different directory.
We need to make a directory for global installations, in this example inside user directory:
mkdir ~/.npm-global
We configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
Open or create a ~/.profile file and add this line:
export PATH=~/.npm-global/bin:$PATH
We update your system variables:
source ~/.profile
Now we can test by installing a package globally without using root permissions.
npm install -g jsonfile
Another option to avoid all these steps and modifying ~/.profile, it will be by defining an ENV variable with the following command(:
NPM_CONFIG_PREFIX=~/.npm-global
npm reference
I had the EACCES permission error too. I did a fresh install of Ubuntu 18.04. The 16.04 version may not be much different. It all works for me. Hope this helps.
----------- FOR YOU, YOU SHOULD APPLY THIS CODE FROM HERE
sudo apt-get install curl software-properties-common
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt install nodejs
node -v
npm -v
npm init
whoami
which npm # returned /usr/bin
npm config get prefix # returned /usr
npm config set prefix /usr/bin
npm config get prefix
ls -la /usr/bin/npm # has a symbolic link to ../lib/node_modules/npm/bin/npm-cli.js
sudo chown -R your_user /usr/bin/npm # NOT /usr/bin or we lock out sudo too!!!!
sudo chown -R your_user app-folder/
ls -la /usr/bin/npm
npm init # I was curious to see if this still works
npm install # WORKS GREAT!!! No need for sudo now.:)
----------- TO THERE
THIS IS THE USE CASE I WORKED ON AFTER I INSTALLED THE ABOVE. YOURS SHALL WORK TOO IF THE ABOVE IS WELL SET UP.
npm start # script
npm run start:prod # works as well
npm i debug --save-dev # works but need to install 'make'
sudo apt install build-essential
npm i debug --save-dev # installed and launched successfully!
Note: if you were to install
npm i debug --global instead,
you may still get that EACCES permission error as your local user will not be able to access root permissions elsewhere in your file system. That's why we use 'change ownership' (i.e. chown your_user: see above in the code).

Angular CLI cannot install errno -13

could anyone advise what I should do please?
My node and npm version as follows:
$ viviantekiMacBook-Air-2:~ Vivi1an$ node -v
v8.11.1
$ viviantekiMacBook-Air-2:~ Vivi1an$ npm -v
5.6.0
I tried to install Angular CLI by following the instructions on their website but I got an error after I typed in npm install -g #angular/cli
Error info as below:
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
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: '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! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/Vivi1an/.npm/_logs/2018-04-02T09_00_20_531Z-debug.log
viviantekiMacBook-Air-2:~ Vivi1an$
I have downloaded node.js in a local folder to use Babel, not sure if this has anything to do with it?
Many thanks!
sudo npm install -g #angular/cli
i have the same problem I give way perhaps work with you
This is how to solve it. Run this command:
sudo chown -R $USER /usr/local/lib/node_modules
sudo means we are running this command as root, the system super user. This is because we don’t have permission to write to that folder, but root will be able to fix any permission. This command also means the system will ask for your password to confirm.
chown is the command we use to change the owner of a file or folder. We set the -R option to change the owner recursively, so we also get owner access to all the files already contained in there.
$USER is an environment variable automatically set to your username.
And the final piece is the folder path.
Running this path will make the folder yours, so you can safely run your npm install -g commands!
i go with the previous answer i put it and i install angular well,
but i appear for me another maybe also related with
npm audit
for resolve, it follows this question link answer
how to fix the npm audit report
i hope is a benefit for you

Macbook React Native install

npm WARN checkPermissions Missing write access to
/usr/local/lib/node_modules 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: '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! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in: npm ERR!
/Users/fatihcanbekli/.npm/_logs/2017-12-29T22_23_07_790Z-debug.log
When I try to start. npm install - g react-native-cli. I am taking this error. What can I do?
This is simply a permission problem. Basically NPM is trying to write to a directory that is owned by root. There are a few ways to get around this.
You can use the recommended solution from the docs here. Basically it suggest you use a package manager. For example Home Brew is a great one if you are using OSX.
You can install the packages using sudo. This could cause you other problems though and a lot of people freak out about this. In other words,
sudo npm install - g react-native-cli
You could update the permissions on this folder allowing you to install things to it. This would mean that your user has the right to write to /usr/local/lib/. Type this command into the terminal,
sudo chown -R $USER /usr/local
Sometimes depending on your system different steps need to be taken. This is actually a very common problem and typically happens to us when we update our systems OS. If this is the first time you have seen this chances are you will see it again. So try and look around and read about the problem. You will notice a lot of the times the solution is to use something like homebrew to install things. Sometimes homebrew can have a permission problem when a new OS comes out. These solutions are always some combination of chown or chmod to give a user's account write access to a specific directory.
For more information on HomeBrew please see this link.
i have same issue with this but i just typing npm install -g install-react-native-app then i put sudo in the front so seem like this sudo npm install -g install-react-native-app and the file is work.

Error: EACCES: permission denied when running `npm install` on Elastic Beanstalk

I've provisioned a default clean node.js app via Elastic Beanstalk, and have a node.js script trying to run npm install inside the project directory (/var/app/current/deploy-dist), however, the following permission error is thrown:
npm WARN locking Error: EACCES: permission denied, open '/tmp/.npm/_locks/staging-f212e8d64a01707f.lock'
npm WARN locking at Error (native)
npm WARN locking /tmp/.npm/_locks/staging-f212e8d64a01707f.lock failed { Error: EACCES: permission denied, open '/tmp/.npm/_locks/staging-f212e8d64a01707f.lock'
npm WARN locking at Error (native)
npm WARN locking errno: -13,
npm WARN locking code: 'EACCES',
npm WARN locking syscall: 'open',
npm WARN locking path: '/tmp/.npm/_locks/staging-f212e8d64a01707f.lock' }
npm WARN deploy-dist No description
npm WARN deploy-dist No repository field.
npm WARN deploy-dist No license field.
npm ERR! Linux 4.4.35-33.55.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v6.9.1-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v6.9.1-linux-x64/bin/npm" "install"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! path /tmp/.npm/_locks/staging-f212e8d64a01707f.lock
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall open
npm ERR! Error: EACCES: permission denied, open '/tmp/.npm/_locks/staging-f212e8d64a01707f.lock'
npm ERR! at Error (native)
npm ERR! { Error: EACCES: permission denied, open '/tmp/.npm/_locks/staging-f212e8d64a01707f.lock'
npm ERR! at Error (native)
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'open',
npm ERR! path: '/tmp/.npm/_locks/staging-f212e8d64a01707f.lock' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! /var/app/current/deploy-dist/npm-debug.log
The package.json is just a:
{
"dependencies": {
"node-fetch": "^1.3.3"
}
}
Running npm install with sudo obviously works, but is preferred to be avoided as a solution.
Setting NPM_CONFIG_PREFIX to a directory at ~ as per npm docs suggestion didn't work either, and the problem persists.
I suspect the problem lies in incorrect permissions for /tmp/.npm, which are
drwxr-xr-x 114 root root 4.0K Dec 27 17:04 .npm
This is confusing, as I expected a simple npm install to work out of the box.
UPDATE: Should not that the project directory already contains a node_modules folder, but even removing it and running npm install doesn't fix it.
I had this problem! You can use ebextensions to create a post-deploy script that changes the permissions of the tmp/npm/.locks folder.
In your node.js project, create a .ebextensions folder if you haven't got one already. Then, add a new config file, e.g. 00_create_postdeploy_script.config, with the following yaml:
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/99_fix_node_permissions.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
chown -R nodejs:nodejs /tmp/.npm/_locks/
When you deploy, this will create a script in /opt/elasticbeanstalk/hooks/appdeploy/post called 99_fix_node_permissions.sh, which looks like this:
#!/usr/bin/env bash
chown -R nodejs:nodejs /tmp/.npm/_locks/
Because it's in that post folder, it will be run automatically after your app has deployed -- and hence change the permissions as required.
EDIT: If you're having trouble with the permissions of the whole .npm folder, then you should change the last line of the config file to:
chown -R nodejs:nodejs /tmp/.npm/
I have had this problem in past and in my case cleaning the cache fixed my issue.
Please try this
npm cache clean
Hope it helps.
The following command will fix the issue. it worked for me.
sudo chown -R 1000:1000 "/home/user/.npm"

Resources