permissions installing yeoman with npm - eaccess? - node.js

I installed npm with homebrew and had to link it - i'm thinking this may be some part of the issue. This is all new to me so I am seeking any help. I am trying to install yeoman and some other things on a computer with
npm install -g yo
however it is spitting back the error -
npm ERR! Darwin 14.0.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "yo"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! path /Users/Lynda/npm-global/lib/node_modules/yo/lib
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! Error: EACCES, unlink '/Users/Lynda/npm-global/lib/node_modules/yo/lib'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES, unlink '/Users/Lynda/npm-global/lib/node_modules/yo/lib']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! path: '/Users/Lynda/npm-global/lib/node_modules/yo/lib' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! error rolling back Error: EACCES, unlink '/Users/Lynda/npm-global/lib/node_modules/yo/lib'
npm ERR! error rolling back at Error (native)
npm ERR! error rolling back { [Error: EACCES, unlink '/Users/Lynda/npm-global/lib/node_modules/yo/lib']
npm ERR! error rolling back errno: -13,
npm ERR! error rolling back code: 'EACCES',
npm ERR! error rolling back path: '/Users/Lynda/npm-global/lib/node_modules/yo/lib' }
I did a bunch of googling and can't find anything, could use some help! I'd like to avoid sudo'ing if I can. Thanks.

My preferred way of installing node & npm on OSX:
Install node via homebrew without npm:
brew update
brew install node --without-npm
echo prefix=~/.node >> ~/.npmrc
Then install npm via the install script on npmjs.org:
If you're wild and crazy:
curl -L https://www.npmjs.org/install.sh | sh
Otherwise, download https://www.npmjs.org/install.sh, inspect to your satisfaction, chmod +x and execute it.
Then add $HOME/.node/bin to your path.
Note: If you've previuously installed node + npm via the graphical installer or homebrew, you'll want to remove the previous install before installing again. For instance, if you installed via the graphical installer:
rm -rf /usr/local/lib/node_modules
rm -rf /usr/local/include/node
rm -rf ~/.npm
mv ~/.npmrc ~/.npmrc-old

you can own the directory that npm is trying to install to, I too disliked having to sudo. In fact, NPM states that you shouldn't sudo as well.
try:
sudo chown -R `whoami` /Users/Lynda/npm-global/lib/node_modules
remember that this will bind it to your current user, whoami is a bash variable to get your user name.

If you would like to avoid sudo'ing, I recommend you use a version manager for node such as nvm. This allows to install global packages without sudo and also to run different versions of node and/or io.js side by side.

If you see this:
npm ERR! Please try running this command again as root/Administrator.
Then sudo is probably exactly what you need to use. Try sudo npm install -g yo

As this line
npm ERR! Please try running this command again as root/Administrator
states, you need to have admin credentials to install the yeoman. So you can try with sudo npm install -g yo

Related

angular install cli errno -13 [duplicate]

This question already has answers here:
Missing write access in mac to /usr/local/lib/node_modules
(9 answers)
npm install -g less does not work: EACCES: permission denied
(14 answers)
Closed 2 years ago.
i am trying to install npm install -g #angular/cli
and i get this error
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! 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/admin/.npm/_logs/2019-08-04T05_20_10_235Z-debug.log
Tried following Commands repeatedly still did not worked.
1- i uninstall nodejs and reinstall old version
~ brew uninstall node
~ which node
~ rm -rf /usr/local/bin/node
~cd /usr/local/lib
~ sudo rm -rf node
~ sudo rm -rf node_modules
2- clean cash
~ npm cache verify --force
~ npm cache clear --force
~ npm uninstall -g #angular/cli
~ npm install -g #angular/cli
node version
v8.16.0
npm version
6.4.1
Since the latest version of Angular 8, it requires Node.js version 10.9.0 or later.
Upgrade Node.js on your OS.
Check at documentation to setup your environment : https://angular.io/guide/setup-local
From the error message it seems like a folder does not have write permission.
If you're on a windows machine, open a command prompt in "Run as Administrator" and execute the command.
If you're on a Mac, you'll have to give it permission using chmod 777 /usr/local/lib/node_modules
On linux, I had to use sudo npm install...

Error: EACCES: permission denied when trying to install ESLint using npm

I'm trying to install ESLint with npm by going:
npm install -g eslint
However I get the following error:
Deans-Air:~ deangibson$ npm install -g eslint
npm ERR! tar.unpack untar error /Users/deangibson/.npm/eslint/2.4.0/package.tgz
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "eslint"
npm ERR! node v4.2.3
npm ERR! npm v2.14.7
npm ERR! path /usr/local/lib/node_modules/eslint
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/eslint'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/eslint']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/eslint',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/eslint',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25',
npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53',
npm ERR! 'FSReqWrap.oncomplete (fs.js:82:15)' ] }
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! /Users/deangibson/npm-debug.log
And to be honest I get this every single time I try and install something with npm. Sometimes using 'sudo' works, sometimes it doesn't... How can I fix this once and for all?
Use --unsafe-perm=true and --allow-root flags with npm install like below:-
sudo npm install -g eslint --unsafe-perm=true --allow-root
it worked like charm for me.
This problem is well documented in the npm docs: Fixing npm permissions.
You have 2 solutions available:
Option 1: Change npm's default directory to a hidden directory in your home folder
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
source ~/.profile
Option 2: Use a package manager that takes care of this for you
brew install node
Running the following command solved the issue for me while installing my packages.json :
sudo npm install --unsafe-perm=true --allow-root
To install only the package which caused the issue:
sudo npm install -g --unsafe-perm=true --allow-root eslint
sudo npm install -g --unsafe-perm=true eslint
is sufficient.
Use sudo before tns and it is work for me
Example:
sudo tns create Tekmo --template tns-template-hello-world
if I have used sudo then not found error like to create postinstall.js
Error: EACCES: permission denied
guys, I have fixed it simplely by
sudo npm install
I have tried the toppest answer, it works well too.
you can login as root using sudo su. First run the command sudo su on your terminal, then give your login password. Finally execute your expected command npm install -g eslint. It works for me.
For MAC user provide the access permission to project directory folder
Right click on project directory folder
Select get info
Provide the access permission - Apply to inclosed items
Just had the same error while running
npm install -g #ionic/cli native-run cordova-res
To fix, run the following
sudo apt update
sudo apt upgrade -y
I had read the already present solutions but thought there was something else, UNSAFE isn't a safe keyword, lol. While running the command with the --unsafe-perm=true, I noticed it downloading what seemed to be update binaries.
So, I updated and tried again.

npm install not working, throwing errors

I am trying to install yo and a few other packages in nodejs, however I keep getting errors. I am new to node so I am a little lost.
I am running Mac OS X 10.10.3. The command I am using is
sudo npm install --global yo
Doing this gives me the following errors.
> spawn-sync#1.0.13 postinstall /usr/local/lib/node_modules/yo/node_modules/cross-spawn/node_modules/spawn-sync
> node postinstall
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
node.js:720
var cwd = process.cwd();
^
Error: EACCES, permission denied
at Error (native)
at Function.startup.resolveArgv0 (node.js:720:23)
at startup (node.js:63:13)
at node.js:814:3
npm ERR! Darwin 14.3.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "--global" "yo"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! code ELIFECYCLE
npm ERR! spawn-sync#1.0.13 postinstall: `node postinstall`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the spawn-sync#1.0.13 postinstall script 'node postinstall'.
npm ERR! This is most likely a problem with the spawn-sync package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node postinstall
npm ERR! You can get their info via:
npm ERR! npm owner ls spawn-sync
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/XXXXXXX/npm-debug.log
In general, you should not be using sudo to install node modules.
Instead, use sudo to fix your folder permissions to allow you to do global npm installs.
Take ownership of the .npm directory with
sudo chown -R $(whoami) ~/.npm
And write permission for the node_modules directory with
sudo chown -R $USER /usr/local/lib/node_modules
Then try to run your npm install command again without sudo.
From your Reddit post, I know that
sudo npm cache clean fixed the issue for you.
Figured someone should answer here so anyone else looking to solve this can find it.
Running the following commands should solve the problem.
sudo npm cache clean
sudo npm install -g yo

Error installing Gulp

I am pretty new to using terminal and installing gulp, but I am running through a few errors. Errors keep popping up and I am not sure why. My goal for right now is to install gulp globally, but not sure if any old files are interfering. Maybe a clean out and reinstall would work? Error is below. Thanks!
pm ERR! tar.unpack untar error /Users/.npm/gulp/3.9.0/package.tgz
npm ERR! Darwin 14.1.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "gulp"
npm ERR! node v0.12.4
npm ERR! npm v2.10.1
npm ERR! path /usr/local/lib/node_modules/gulp
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/gulp'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/gulp']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/gulp',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/gulp',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25',
npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53',
npm ERR! 'FSReqWrap.oncomplete (fs.js:95:15)' ] }
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! /usr/local/bin/npm-debug.log
Other answers are bypassing these issues by the use of sudo or su root. I personally don't recommend this. The reason it works is because on OSX the global npm module directory has stricter permissions. Running your commands with root privileges just to get around permissions issues is likely only going to cause you headaches down the road and open you up to security vulnerabilities. At the very least it's going to cause you to have to use sudo constantly when trying to do routine node/npm things. The safer way would be to change the permissions of just that directory. However, even that can sometimes cause nightmares.
My alternative recommendation to the other suggestions here is to use nvm.
You can install it with curl (you have this already, just paste the below command):
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash
Or you can use Homebrew if you have that installed:
brew install nvm
Once installed, you'll be able to easily install any node or iojs version that you want.
nvm install node
The above command will install the latest version of node. The nice part is that all your node/iojs installations are managed within ~/.nvm/, meaning they are inside your home directory where you'll always have full access permissions and won't ever need to use sudo.
You dont have the rights to write un /sur/local
Either you run sudo npm install -g gulp or give your user the rights to write in /usr/local

npm install is not working

I used this installation guide to install nodejs:
https://github.com/joyent/node/wiki/installing-node.js-via-package-manager#debian-and-ubuntu-based-linux-distributions
I am trying to use npm install and I had this error when I used this command:
npm install --global yo bower grunt-cli
npm ERR! Error: EACCES, mkdir '/home/alexfqc/.npm-packages/lib/node_modules'
npm ERR! { [Error: EACCES, mkdir '/home/alexfqc/.npm-packages/lib/node_modules']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/home/alexfqc/.npm-packages/lib/node_modules',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/home/alexfqc/.npm-packages/lib/node_modules/grunt-cli',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/lib/node_modules/npm/node_modules/fstream/lib/writer.js:171:23',
npm ERR! '/usr/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53',
npm ERR! 'Object.oncomplete (fs.js:108:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
I was following the yeoman instructions, and there is a page for this error
After do this steps the error still continue.
Then I tried this commands:
sudo chmod -R 755 /home/alexfqc/.npm-packages
sudo chown -R root /home/alexfqc/.npm-packages
and did not work.
I am trying the entire day install nodejs correctly to use yeoman, bower and grunt but it seems impossible.
I tried other ways of installing nodejs but another error appeared.
I anyone could help to fix this error or show a way to install the nodejs, yeoman, bower and grunt I would be very grateful.
You have an access error, try using sudo npm install --global yo bower grunt-cli to perform install as root
Alternate - Instead of giving ownership of folder to root, give it to your user account with: sudo chown -R $USER /home/alexfqc/.npm-packages

Resources