I am trying to install firebase and create-react-native-app on my terminal and keep getting the same errors on my terminal. Can someone please explain to me the root of my issue and a solution.
Please explain how i might be able to change my permissions
npm install -g create-react-native-app
npm install firebase-tools -g
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:
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).
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/matthewsixt/.npm/_logs/2018-12-21T18_46_00_558Z-debug.log
Can someone please explain to me the root of my issue
npm is trying to write to a directory it doesn't have permission to write to.
Please explain how i might be able to change my permissions
As you can read on the npm docs, if you see an EACCES error when you try to install a package globally, you can either manually change npm’s default directory or reinstall npm with a node version manager.
Change npm’s default directory
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
This creates a directory for global installations and configures npm to use the new directory path. Then create a ~/.profile file (or open it if one exists) and add:
export PATH=~/.npm-global/bin:$PATH
Reload your shell, then reattempt your install to check that it is working:
source ~/.profile
npm i -g create-react-native-app
Use a version manager
This is my preferred option, as you can install as many versions of Node and npm as you like and change between them at will. It also totally negates the permissions issue.
The version manager I use is nvm. To install it, there is a handy one-liner using cURL:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
To verify the install:
command -v nvm
which should output 'nvm' if the installation was successful.
There are also a bunch of other installation methods listed on the project's homepage.
Once you have it installed, you can see what versions of Node are available with:
nvm ls-remote
And install a version using:
nvm install xx.xx.xx
(where xx.xx.xx is the version number).
If you'd like to read more about using nvm, this article is helpful: Installing Multiple Versions of Node.js Using nvm.
Using sudo
You'll probably find that prefixing sudo to your command fixes the issue. However, please don't do this.
Installing random code from the internet with admin rights is a really, really bad idea.
Related
Two days dealing with this issue and it is winning.
I have a fresh install of Windows 10 host, running the latest versions of Vagrant, laravel/homestead (Ubuntu 18.04 LTS box, v 6.0.0), Virtualbox, laravel, git for windows, node.js for windows.
vagrant, git, virtualbox are set to run as administrator in windows.
I create a Laravel project called blog like this:
vagrant#homestead:~/src$ composer create-project --prefer-dist laravel/laravel blog
All creates OK. I then try and install npm like this:
vagrant#homestead:~/src/blog$ npm install -g npm#latest
And I get:
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm
npm WARN checkPermissions Missing write access to /usr/lib/node_modules
npm ERR! path /usr/lib/node_modules/npm
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules/npm'
npm ERR! { Error: EACCES: permission denied, access '/usr/lib/node_modules/npm'
npm ERR! stack: 'Error: EACCES: permission denied, access \'/usr/lib/node_modules/npm\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/lib/node_modules/npm' }
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/vagrant/.npm/_logs/2018-05-05T00_57_41_110Z-debug.log
But when i check vagrant user permissions:
vagrant#homestead:~/src/blog$ groups
vagrant adm cdrom sudo dip www-data plugdev lxd lpadmin sambashare
So I solve this with the not recommended by npm message:
vagrant#homestead:~/src/blog$ sudo npm install -g npm#latest
I now go and install an npm package like highcharts:
vagrant#homestead:~/src/blog$ npm install --save highcharts
npm WARN rollback Rolling back highcharts#6.1.0 failed (this is probably harmless): ETXTBSY: text file is busy, unlink '/home/vagrant/src/blog/node_modules/highcharts/package.json.2262439515'
npm ERR! path /home/vagrant/src/blog/node_modules/highcharts/package.json.2262439515
npm ERR! code ETXTBSY
npm ERR! errno -26
npm ERR! syscall rename
npm ERR! ETXTBSY: text file is busy, rename '/home/vagrant/src/blog/node_modules/highcharts/package.json.2262439515' -> '/home/vagrant/src/blog/node_modules/highcharts/package.json'
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vagrant/.npm/_logs/2018-05-05T01_10_24_241Z-debug.log
I try sudo to install package, same result
vagrant#homestead:~/src/blog$ sudo npm install --save --no-bin-links highcharts
npm WARN rollback Rolling back highcharts#6.1.0 failed (this is probably harmless): ETXTBSY: text file is busy, unlink '/home/vagrant/src/blog/node_modules/highcharts/package.json.1984492036'
npm ERR! path /home/vagrant/src/blog/node_modules/highcharts/package.json.1984492036
npm ERR! code ETXTBSY
npm ERR! errno -26
npm ERR! syscall rename
npm ERR! ETXTBSY: text file is busy, rename '/home/vagrant/src/blog/node_modules/highcharts/package.json.1984492036' -> '/home/vagrant/src/blog/node_modules/highcharts/package.json'
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vagrant/.npm/_logs/2018-05-05T01_58_13_140Z-debug.log
The result is a highchatrts folder in node_modules with only the packaje.json.1984492036 file in it.
I cannot seem to find a way around this. Using --no-bin-links gives the same error.
Any help is appreciated.
I got it all working by running npm install from the git host os, not from the ubuntu vm. Not what I wanted but I move forward and have learned something and creeped closer to insanity...
I had this same issue two days ago, try running sudo npm install --unsafe-perm , undo any changes you made first though, cause i don't know how valet works (sad Linux user)
This is my first time posting here and I was hoping to find some help...
So I have been trying to install Cordova and Ionic on my Mac using npm command... This is honestly the first time for me to try to install something through command line on Mac could you help me out understand what is going on?
npm install -g cordova ionic
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/Shiro/.npm/_logs/2018-01-07T09_07_09_230Z-debug.log
I somewhat understood that it has to do with a permission error (Not completely sure tho) so I looked around and found this command to change ownership (I honestly have no idea what is that for...)
sudo chown -R
so after that I was supposed to enter a password but I couldn't figure out for what it should be cause the one for permissions I use did not work...
There are several recommended approaches for installing npm for the MacOS.
Using HomeBrew to Install npm
Many Macintosh developers use Homebrew, a valuable tool for managing apps and files.
Before starting delete nodejs.
To install Homebrew, click here.
After you've installed Homebrew, run brew install node
Homebrew will install Node.js and npm.
After that just run npm install -g cordova ionic
I am trying install typescript with command npm install -g typescript, and it returns this error:
npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR! at Error (native)
npm ERR! { Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR! at Error (native)
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! Linux 4.4.0-93-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "typescript"
npm ERR! node v6.11.2
npm ERR! npm v3.10.10
npm ERR! path npm-debug.log.1024969454
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall open
npm ERR! Error: EACCES: permission denied, open 'npm-debug.log.1024969454'
npm ERR! at Error (native)
npm ERR! { Error: EACCES: permission denied, open 'npm-debug.log.1024969454'
npm ERR! at Error (native)
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'open',
npm ERR! path: 'npm-debug.log.1024969454' }
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! /npm-debug.log
jramirez#jramirez:/$ ^C
jramirez#jramirez:/$ npm install typescript
npm WARN checkPermissions Missing write access to /
/
└── typescript#2.5.2
npm WARN enoent ENOENT: no such file or directory, open '/package.json'
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm WARN !invalid#1 No license field.
npm ERR! Linux 4.4.0-93-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "typescript"
npm ERR! node v6.11.2
npm ERR! npm v3.10.10
npm ERR! path /
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/'
npm ERR! at Error (native)
npm ERR! { Error: EACCES: permission denied, access '/'
npm ERR! at Error (native) errno: -13, code: 'EACCES', syscall: 'access', path: '/' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Linux 4.4.0-93-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "typescript"
npm ERR! node v6.11.2
npm ERR! npm v3.10.10
npm ERR! path npm-debug.log.2387664261
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall open
npm ERR! Error: EACCES: permission denied, open 'npm-debug.log.2387664261'
npm ERR! at Error (native)
npm ERR! { Error: EACCES: permission denied, open 'npm-debug.log.2387664261'
npm ERR! at Error (native)
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'open',
npm ERR! path: 'npm-debug.log.2387664261' }
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! /npm-debug.log
Additionally, I run npm install typescript (without -g), but it doesn't work. Does there exist any other way to install typescript?
My OS is Linux Ubuntu 16.04.
I seldom use node and don't know like to fix this issue.
My question is: exactly which directories need that permission?
It's not recommended to use sudo with npm install, follow the steps from npmjs official docs instead :)
Make a directory for global installations:
mkdir ~/.npm-global
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
Back on the command line, update your system variables:
source ~/.profile
Test: Download a package globally without using sudo.
npm install -g typescript
Source: https://docs.npmjs.com/getting-started/fixing-npm-permissions
When installing global packages in ubuntu, you need special write permissions as you are writing to the usr/bin folder. It is for security reasons.
So, everytime you install a global package, use:
sudo npm install -g [package-name]
for your specific case:
sudo npm install -g typescript
When you try it without -g all that you are doing is installing the package locally in whatever folder you are in:
so: npm install typescript will create a node_modules folder in the folder you are in.
I have same issue with webpack server installation on globally, Use steps Solved my issue, my be work for you.
Steps mention above There: Back-up your computer before you start.
Make a directory for global installations:
1. mkdir ~/.npm-global
Configure npm to use the new directory path:
2. npm config set prefix '~/.npm-global'
Open or create a ~/.profile file and add this line:
3. export PATH=~/.npm-global/bin:$PATH
Back on the command line, update your system variables:
4. source ~/.profile
Test: Download 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
Not very sure if this could be the right solution to this problem, but I hope this could help others with similar situation that already tried the following:
Applied the recommendation on the npm website
Checked for the right permissions for the node_modules folder and found nothing wrong
Used sudo npm install <package> (solution which I do not recommend anyway) with or without -g and had no expected result
The solution to this problem pointed out when I noticed that while I was trying to install the axios package with npm, the directory containing the entire project was opened in Visual Studio Code. So I closed it and retried installation again.
Surprise, the installation worked like a charm.
For trying to replicate same problem I was using Ubuntu 18.04 LTS on WSL (maybe this has something to do with Windows permissions)
This could be the solution for this question also:
Error: EACCES: permission denied, access '/usr/local/lib/node_modules' react
1) Go to the directory “/usr/local/lib/node_modules”
2) Click on the folder and right click Get info
3) Click the lock at the bottom right
4) Key in your window password to unlock
5) Check both the value of Wheel and Everyone to Read & Write
6) Go back to your terminal and try to install the Typescript again
It is recommended to use nvm to manage your node versions and npm suggests this to be the recommended solution of access errors: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
Please follow npm site - https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
"If you see an EACCES error when you try to install a package globally, you can either:
Reinstall npm with a node version manager (recommended),
or
Manually change npm’s default directory"
I followed recommended way - installed nvm. its resolved my issue
this worked for me.
sudo npm install -g coffee-script
then
sudo npm install -g typescript
I am currently unable to install NPM on Mac OS, I have looked all over the place for someone with the same error, but I can't seem to find any. Could anyone give me a hand? This is what I get after running the curl command to install NPM:
All clean!
npm-install-94139.sh: line 302: 94407 Segmentation fault: 11 "$node" cli.js rm npm -gf
npm ERR! addLocal Could not install .
npm ERR! Error: EACCES, open '/Volumes/MacintoshHD/Users/Sebastian/.npm/3a52ce78-.lock'
npm ERR! { [Error: EACCES, open '/Volumes/MacintoshHD/Users/Sebastian/.npm/3a52ce78-.lock']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/Volumes/MacintoshHD/Users/Sebastian/.npm/3a52ce78-.lock' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 12.5.0
npm ERR! command "/usr/local/bin/node" "/private/var/folders/52/msjnslgn4qnfjgxfvg28f8kc0000gn/T/npm.94143/package/cli.js" "install" "-gf"
npm ERR! cwd /private/var/folders/52/msjnslgn4qnfjgxfvg28f8kc0000gn/T/npm.94143/package
npm ERR! node -v v0.8.19
npm ERR! npm -v 1.1.71
npm ERR! path /Volumes/MacintoshHD/Users/Sebastian/.npm/3a52ce78-.lock
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, open '/Volumes/MacintoshHD/Users/Sebastian/.npm/3a52ce78-.lock'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /private/var/folders/52/msjnslgn4qnfjgxfvg28f8kc0000gn/T/npm.94143/package/npm-debug.log
npm ERR! not ok code 0
It failed
The solution on this other question seems better than messing around with NVM - npm throws error without sudo
SOLUTION:
You need to unlock permissions in home directory, like Noah says.
sudo chown -R `whoami` ~/.npm
You also need to write it to your library as well, like Xilo says.
sudo chown -R `whoami` /usr/local/lib/node_modules
My guess is that a directory used by npm (maybe /usr/local or something in your home folder) has the wrong permissions. Installing with sudo might work now but it can also bite you later since you'll definitely create files and directories as root, possibly causing problems later when npm tries to cache things.
My advice would be to uninstall, then reinstall via nvm instead. This does a great job of managing different node versions under ~/.nvm without having to use sudo.
Try clearing npm cache with
npm cache clean
Hope that helps.
when all else fails, clear you cache
Did you try "sudo" with your curl command?
Also, if you install a new version of Node, it now includes NPM, so you don't have to even install NPM separately..
From the NPM readme file: https://npmjs.org/doc/README.html
SUPER EASY INSTALL
npm comes with node now.
Windows Computers
Get the MSI. npm is in it.
Apple Macintosh Computers
Get the pkg. npm is in it.
Other Sorts of Unices
Run make install. npm will be installed with
node.
If you want a more fancy pants install (a different version, customized paths, etc.) then read on...
Node and npm are both installed and up to date but keep getting this error when trying to install coffeescript. I am still new to programming so any advice would be greatly appreciated.
test-macbook:~ Test$ npm -v
1.1.0-3
test-macbook:~ Test$ node -v
v0.6.8
test-macbook:~ Test$ npm install -g coffee-script
npm http GET https://registry.npmjs.org/coffee-script
npm http 304 https://registry.npmjs.org/coffee-script
npm ERR! Could not create /usr/local/lib/node_modules/___coffee-script.npm
npm ERR! error installing coffee-script#1.2.0
npm ERR! Error: EACCES, permission denied '/usr/local/lib/node_modules/___coffee-script.npm'
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR!
npm ERR! System Darwin 11.2.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "coffee-script"
npm ERR! cwd /Users/Dylan
npm ERR! node -v v0.6.8
npm ERR! npm -v 1.1.0-3
npm ERR! path /usr/local/lib/node_modules/___coffee-script.npm
npm ERR! code EACCES
npm ERR! message EACCES, permission denied '/usr/local/lib/node_modules/___coffee-script.npm'
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/Dylan/npm-debug.log
npm not ok
Following the advice of nmp author Isaac Z. Schlueter:
I strongly encourage you not to do package management with sudo!
Instead of sudo npm install ... you could instead change permissions on your /usr/local directory:
sudo chown -R $USER /usr/local
After doing this once, you should be able to npm install ... (without sudo).
I realize this is an older thread, but I just ran across this and wanted to update the last answer.
Changing the owner of the entire /usr/local directory is a horrible answer to this question. There's no reason at all that you should do that.
If you look at the error message from npm, it's being denied write permissions on /usr/local/lib/node_modules/ I know that after installing node and npm on OS X Mavericks, its default owner is a non-existent user.
0 drwxr-xr-x 3 24561 wheel 102 Jan 23 14:17 node_modules
If you're just running node/npm on your local development machine, just change the owner of the node_modules folder to your user:
sudo chown -R yourusername /usr/local/lib/node_modules
Then you can install modules with npm without sudo and without changing the owner of /usr/lib from root, as it should be.
The error message is fairly clear:
npm ERR! Error: EACCES, permission denied '/usr/local/lib/node_modules/___coffee-script.npm'
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
You can't install it in /usr/local/lib/node_modules because you don't have the necessary permissions. Try using sudo:
dylan-hermans-macbook:~ sudo npm install -g coffee-script
The npm author recommends not using sudo because packages can run arbitrary commands so sudo npm install is dangerous. He suggests switching the ownership of /usr/local to your user. I think that's horribly advice that just gives you a false sense of security: if a package can run arbitrary commands then it can mess with your home directory (including all your personal data, executables, config and startup files, ...) regardless of sudo or who owns /usr/local so not using sudo really doesn't do much for you. If you don't trust a package then don't install it; if you don't trust a package then how can you even use it? The /usr/local tree is still a system directory tree and OSX is still a multi-user operating system.
IMO a much better solution is twofold:
Don't install or use any packages that you don't trust. If you install it then you're trusting that code to be you (unless you're always going to run it in a jail of some sort but if you're going to those lengths you're probably better off writing the code yourself).
Leave sudo and /usr/local alone and install it all inside your home directory. You'll be subject to most of the same dangers as using sudo or changing the /usr/local ownership but at least you won't be picking up bad habits.