npm install -g webpack gives tar.unpack untar error - node.js

I created a new user on my Mac and tried this. This normally works in my other account. This new user is an administrator also.
npm ERR! tar.unpack untar error /Users/test/.npm/webpack/1.11.0/package.tgz
npm ERR! Darwin 14.4.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "webpack"
npm ERR! node v0.12.4
npm ERR! npm v2.10.1
npm ERR! path /usr/local/lib/node_modules/webpack
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/webpack'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/webpack']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/webpack',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/webpack',
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/test/WebstormProjects/babel-test/npm-debug.log
I am not very good with the UNIX stuff and things, I just wish these things would be more easy.

From the looks of it, since it says EACCES, it is probably getting an access denied from the system. If you are installing globally on unix you must use sudo.
$ sudo npm install -g webpack

Start using nvm and it will save you from using sudo at all.
https://github.com/creationix/nvm

Related

How do I install the latest npm version on my shared server through SSH

I have been trying to update the npm on the shared hosting server (linux) through SSH using this command: npm i npm#latest -g
I keep getting this error message:
npm ERR! Linux 3.10.0-714.10.2.lve1.4.66.el6h.x86_64
npm ERR! argv "node" "/usr/bin/npm" "i" "npm#latest" "-g"
npm ERR! node v0.10.47
npm ERR! npm v3.8.3
npm ERR! path /usr/lib/node_modules/npm/node_modules/abbrev
npm ERR! code EACCES
npm ERR! Error: EACCES, access '/usr/lib/node_modules/npm/node_modules/abbrev'
npm ERR! at module.exports (/usr/lib/node_modules/npm/lib/install/access-error.js:4:18)
npm ERR! at /usr/lib/node_modules/npm/lib/install/writable.js:30:25
npm ERR! at /usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:232:16
npm ERR! at Object.oncomplete (fs.js:108:15)
npm ERR! { [Error: EACCES, access '/usr/lib/node_modules/npm/node_modules/abbrev']
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/lib/node_modules/npm/node_modules/abbrev' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
I have tried to follow this advice,
chown -R $USER /usr/local
but no success.
Any advice is welcome

How to install create-react-app through terminal

I am installing create-react-app through terminal. I have checked the node.js version is 4.5.0, which is higher than the requirement here. and the version of npm is 2.15.9. Then I type the command npm install -g create-react-app, there came out such error information:
npm ERR! tar.unpack untar error /Users/xiufenxu/.npm/create-react-app/0.6.0/package.tgz
npm ERR! Darwin 16.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "create-react-app"
npm ERR! node v4.5.0
npm ERR! npm v2.15.9
npm ERR! path /usr/local/lib/node_modules/create-react-app
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/create-react-app'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/create-react-app']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/create-react-app',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/create-react-app',
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/xiufenxu/Documents/UM courses/Fall 2016/CSCI 5117/npm-debug.log
I wondering why I got such errors. Is there anyone who can help me to figure out this problem? Thank you so much!
sudo npm install -g create-react-app
you're running it as a user without root permissions
Restarting my computer fixed it for me

Errors when installing karma througth terminal

I type npm install -g karma and get the following result every time I try:
npm ERR! tar.unpack untar error /Users/Sasha/.npm/karma/0.13.10/package.tgz
npm ERR! Darwin 14.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "karma"
npm ERR! node v4.1.1
npm ERR! npm v2.14.4
npm ERR! path /usr/local/lib/node_modules/karma
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/karma'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/karma']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/karma',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/karma',
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/Sasha/npm-debug.log
Please help!Cannot proceed with my tutorial book!
It's a permissions error. Run the command as the root user (as it clearly suggests in the error):
sudo npm install -g karma

Appium_npm install -g appium please try running this command again as root/Administrator

Am trying to install appium in ubuntu and got the below error.I searched so many articles and installed node through linuxbrew and even changed the permission also but still getting the below error.Can any one help please
npm ERR! tar.unpack untar error /home/ubuntu/.npm/appium/1.3.6/package.tgz
npm ERR! Linux 3.13.0-44-generic
npm ERR! argv "node" "/home/ubuntu/.linuxbrew/bin/npm" "install" "-g" "appium"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! path /home/ubuntu/lib/node_modules/appium
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! Error: EACCES, mkdir '/home/ubuntu/lib/node_modules/appium'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES, mkdir '/home/ubuntu/lib/node_modules/appium']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! path: '/home/ubuntu/lib/node_modules/appium',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/home/ubuntu/lib/node_modules/appium',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/home/ubuntu/.linuxbrew/lib/node_modules/npm/node_modules
/fstream/lib/dir-writer.js:36:23',
npm ERR! '/home/ubuntu/.linuxbrew/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53',
npm ERR! 'FSReqWrap.oncomplete (fs.js:99: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! /home/ubuntu/npm-debug.log
I have tried npm cache clean also but still not working.
What does linuxbrew doctor return?
Try to bash reset.sh --hardcore to completely reset Appium server and all npm modules

Cannot npm install -g without sudo changing prefix

I have done this: https://stackoverflow.com/a/21712034
now my npm config is the following:
npm config get prefix
/home/ranu/npm
But when I run npm install -g grunt-cli I get:
npm ERR! Error: EACCES, mkdir '/usr/lib/node_modules/grunt-cli'
npm ERR! { [Error: EACCES, mkdir '/usr/lib/node_modules/grunt-cli']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/lib/node_modules/grunt-cli',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/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/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.11.0-26-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "grunt-cli"
npm ERR! cwd /home/ranu
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! path /usr/lib/node_modules/grunt-cli
npm ERR! fstream_path /usr/lib/node_modules/grunt-cli
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/grunt-cli'
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! /home/ranu/npm-debug.log
npm ERR! not ok code 0
Why is trying to install it on /usr/lib/node_modules/ if the prefix is set to /home/ranu/npm ?
UPDATE:
I could it make it work with the following command:
npm install --prefix="/home/ranu/npm" -g grunt-cli
There is any way to make it as a default?
Every time I get a new Machine, I run into this.
I'm citing this url fixing-npm-permissions because it's actually NPM's doc, but also because it was the only method that fixed my problem. Not the first search result but the simplest fix for me. I'm sure there are more robust fixes.
Rather than copying and pasting, I'm recommending you just go read it.
I followed step 1, and though according to them it should have worked. But, I ended up also using step 2 for the win.
You can use NVM (Node version manager) and you will never have to bother about sudo for npm commands

Resources