NPM local install tried to write ~/.npm folder which got EACCESS error - npm

I tried to add the 'method-override' package to my current Express project. I ran below command, and got error.
qinguo$ npm install method-override --save
npm WARN package.json redis-url#0.2.0 No repository field.
npm ERR! Error: EACCES, mkdir '/Users/qinguo/.npm/parseurl/1.1.3'
npm ERR! { [Error: EACCES, mkdir '/Users/qinguo/.npm/parseurl/1.1.3']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/Users/qinguo/.npm/parseurl/1.1.3',
npm ERR! parent: 'method-override' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 13.3.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "method-override" "--save"
npm ERR! cwd /Users/qinguo/allcodes/gitebay/NewX/sh-go
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.5.0-alpha-3
npm ERR! path /Users/qinguo/.npm/parseurl/1.1.3
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/Users/qinguo/.npm/parseurl/1.1.3'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/qinguo/allcodes/gitebay/NewX/sh-go/npm-debug.log
npm ERR! not ok code 0
I tried to update npm, re-install, it didn't work.

Try running as sudo -
npm install method-override --save

My guess is that root owns some of the packages in npm's cache. You can check by running:
ls -l ~/.npm
Check if the package causing the error is not owned by your user.
If some of the packages are owned by root, you should chown the ~/.npm folder to your current user.
sudo chown -R `whoami` ~/.npm
Read more: npm cache

Related

npm install -g #sanity/cli commend is not working

I tried to run npm install -g #sanity/cli commend to use Sanity but my return is this..
npm ERR! code EACCES
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/#sanity/cli/bin/sanity
npm ERR! dest /usr/local/bin/sanity
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/#sanity/cli/bin/sanity' -> '/usr/local/bin/sanity'
npm ERR! [Error: EACCES: permission denied, symlink '../lib/node_modules/#sanity/cli/bin/sanity' -> '/usr/local/bin/sanity'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'symlink',
npm ERR! path: '../lib/node_modules/#sanity/cli/bin/sanity',
npm ERR! dest: '/usr/local/bin/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/kevinsong/.npm/_logs/2022-07-27T17_49_06_969Z-debug-0.log
npm -v 8.13.2
What need to be done to run the npm install -g #sanity/cli?
when I do vi /usr/local/bin, I see this
node*
corepack# --> /usr/local/lib/node_modules/corepack/dist/corepack.js
npm# --> /usr/local/lib/node_modules/npm/bin/npm-cli.js
npx# --> /usr/local/lib/node_modules/npm/bin/npx-cli.js
~
It's because your current user doesn't have the permission
you can check the permission
ls -la /usr/local/lib/node_modules
get the permission for sudo access
sudo chown -R $USER /usr/local/lib/node_modules/
Now try with
sudo npm install -g #sanity/cli
Click HERE for more

VS code setting up development tools ERR! permission

I'm new to using VS code, I'm trying to install Hubspot tools using the npm install -g #hubspot/cli
But when i do i get the following
Thorins-MBP:Practice project thorinphoenix$ npm install -g #hubspot/cli
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/#hubspot
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/#hubspot'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/#hubspot'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/#hubspot'
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/thorinphoenix/.npm/_logs/2022-05-18T13_17_18_580Z-debug-0.log
Thorins-MBP:Practice project thorinphoenix$
I used the best fix on this page and it worked. How to fix EACCES issues with npm install
Enter this into terminal:
sudo chown -R `whoami` ~/.npm
sudo chown -R `whoami` /usr/local/lib/node_modules

Installing bower is throwing errors

I can't seem to install bower properly. I don't know what's wrong, but it keeps throwing these errors. Can someone help?
npm ERR! tar.unpack untar error /Users/Jeanwoo/.npm/bower/1.4.1/package.tgz
npm ERR! Darwin 14.0.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "bower"
npm ERR! node v0.12.5
npm ERR! npm v2.11.2
npm ERR! path /usr/local/lib/node_modules/bower
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/bower'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/bower']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/bower',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/bower',
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! /Users/Jeanwoo/npm-debug.log
I'm assuming the command you're running is npm install -g bower (to install Bower globally on your machine).
The error
Please try running this command again as root/Administrator
...makes me think you should try running as root:
sudo npm install -g bower
And then input your password and it should install. If not, what is the command you're running?

Error when I run "npm install -g yo bower grunt-cli gulp" command line

I get this error when I run the command "npm install -g yo bower grunt-cli gulp".
Does any one know what the problem is?
npm ERR! tar.unpack untar error /Users/??????/.npm/grunt-cli/0.1.13/package.tgz
npm ERR! tar.unpack untar error /Users/??????/.npm/yo/1.4.7/package.tgz
npm ERR! tar.unpack untar error /Users/??????/.npm/gulp/3.9.0/package.tgz
npm ERR! tar.unpack untar error /Users/??????/.npm/bower/1.4.1/package.tgz
npm ERR! Darwin 14.3.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "yo" "bower" "grunt-cli"
"gulp"
npm ERR! node v0.12.4
npm ERR! npm v2.10.1
npm ERR! path /usr/local/lib/node_modules/grunt-cli
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/grunt-cli'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/grunt-cli']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/grunt-cli',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/grunt-cli',
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! /Users/??????/npm-debug.log
As Vohuman pointed out, running this as sudo would fix it. You're trying to install the packages globally which requires access to /usr/local which you don't have write privileges to, so as the error message says, please try running this command again as root/Administrator.
Even "logged in" as root (sudo su) [ On CentOS ]
sudo npm install -g ...
Otherwise was still executing as user, possibly the directory owner?

Bower installation on a vagrant machine

I am trying to install bower on a vagrant machine using following command
npm install -g bower
but i am getting following error
npm WARN prefer global bower#1.3.2 should be installed with -g
npm http GET https://registry.npmjs.org/bower
npm http 200 https://registry.npmjs.org/bower
[4mRunning "watch" task[24m
Waiting...npm http GET https://registry.npmjs.org/bower/-/bower-1.3.2.tgz
npm http 200 https://registry.npmjs.org/bower/-/bower-1.3.2.tgz
npm ERR! Error: EACCES, mkdir '/usr/lib/node_modules/bower'
npm ERR! { [Error: EACCES, mkdir '/usr/lib/node_modules/bower']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/lib/node_modules/bower',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/lib/node_modules/bower',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR! '/usr/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
npm ERR! 'Object.oncomplete (fs.js:107:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Linux 3.2.0-23-generic-pae
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "bower" "--no-bin-links"
npm ERR! cwd /vagrant
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! path /usr/lib/node_modules/bower
npm ERR! fstream_path /usr/lib/node_modules/bower
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/lib/node_modules/bower'
npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /vagrant/npm-debug.log
npm ERR! not ok code 0
/tmp/vagrant-shell: line 44: bower: command not found
It seems that bower is not simplly gets installed on a windows machine.
Please help in issue.
Any help will be appericiated.
You need root access for global install.
sudo npm install -g bower