Error installing Gulp - node.js

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

Related

npm ERR! Error: EACCES: permission denied

I'm having this famous issue while trying to install Typescript in my react app. Concretely, I am running this: npm install --save typescript #types/node #types/react #types/react-dom #types/jest
and I am getting this response:
npm ERR! code EACCES npm ERR! syscall rename npm ERR! path
/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/node npm ERR!
dest
/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/.node-8MzkXP42
npm ERR! errno -13 npm ERR! Error: EACCES: permission denied, rename
'/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/node' ->
'/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/.node-8MzkXP42'
npm ERR! [Error: EACCES: permission denied, rename
'/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/node' ->
'/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/.node-8MzkXP42']
{ npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR!
syscall: 'rename', npm ERR! path:
'/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/node', npm
ERR! dest:
'/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/.node-8MzkXP42'
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!
/home/asier/.npm/_logs/2021-04-29T10_48_16_436Z-debug.log
I've checked the ownership of that folder: ls -l/mnt/c/Users/asier/dev/nftgram/web/node_modules/#types/node, and I am the owner of all the files.
I've also tried to install it executing npm set unsafe-perm true
but didn't work.
I've installed npm and node with NVM and I am using Windows 10 with
Ubuntu on WSL.
npm -v: 7.11.1
node -v: v15.14.0
nvm --version: 0.34.0
The weird thing is that I can install other packages with no issues, I just installed react-hook-form for example.
I don't really know which can be the issue and I would be very happy if you guys can give me a clue!
Thank you beforehand for the help! :)
As I saw an error is related to permission. So you need to execute the command with the help of "sudo" like,
sudo npm install --save typescript #types/node #types/react #types/react-dom #types/jest
I had the same problem and the way to fix it was to stop my code that was running (webpack serve). In Windows you can't edit/delete files when those are in use. I think wsl may behave the same as it is a linux subsystem "inside" Windows.

npm - EPERM: operation not permitted on Linux

I'm trying to do the react tutorial on my local machine (centOS)
I ran
sudo npm install -g create-react-app
After running that command I got the following error
npm ERR! Linux 3.10.0-514.el7.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "create-react-app"
npm ERR! node v6.10.3
npm ERR! npm v3.10.10
npm ERR! path /tmp/npm-1422-84cdbe70/registry.npmjs.org/tar/-/tar-2.2.1.tgz
npm ERR! code EPERM
npm ERR! errno -1
npm ERR! syscall open
npm ERR! Error: EPERM: operation not permitted, open '/tmp/npm- 1422-84cdbe70/registry.npmjs.org/tar/-/tar-2.2.1.tgz' while getting shasum for /tmp/npm-1422-84cdbe70/registry.npmjs.org/tar/-/tar-2.2.1.tgz
npm ERR! From: https://registry.npmjs.org/tar/-/tar-2.2.1.tgz
npm ERR! at Error (native)
npm ERR! { Error: EPERM: operation not permitted, open '/tmp/npm-1422-84cdbe70/registry.npmjs.org/tar/-/tar-2.2.1.tgz' while getting shasum for /tmp/npm-1422-84cdbe70/registry.npmjs.org/tar/-/tar-2.2.1.tgz
npm ERR! From: https://registry.npmjs.org/tar/-/tar-2.2.1.tgz
npm ERR! at Error (native)
npm ERR! errno: -1,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'open',
npm ERR! path: '/tmp/npm-1422-84cdbe70/registry.npmjs.org/tar/-/tar-2.2.1.tgz',
npm ERR! parent: 'tar-pack' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
I tried going into the directory and untarring the .tgz file and changing around some of the permissions and nothing worked. I followed some solutions online with similar problems but still no luck.
I also ran
npm cache clear
Can anyone explain why this is happening? Any suggestions?
Running npm cache clear or even npm cache clear -fdoes not always clean all the cache.
Sometimes you should remove the cache files manually.
To do so go to the default NPM cache folder and remove its content:
Default: ~/.npm on linux, or %AppData%/npm-cache on Windows.
Then you can attempt to install your desired package with npm install -g.
Please, avoid using sudo npm install -g because you can mess up the npm permissions. Instead change the permission to npm's default directory, or change npm's default directory to another directory. Further details here:
https://docs.npmjs.com/getting-started/fixing-npm-permissions
WARNING: If npm's default path is just /usr, changing the directory permissions will be harmful.
Try to use $: sudo npm install

Why do i have to call npm link as administrator?

I installed some nodejs packages globally via
sudo npm install gulp -g
Now I (or another developer on the same machine) wants to use it in a project with
me#host:/my/project$ npm link gulp
It fails with
unbuild gulp#3.8.11
npm ERR! Error: EPERM, chmod '/my/projectnode_modules/gulp/bin/gulp.js'
npm ERR! { [Error: EPERM, chmod '/my/projectnode_modules/gulp/bin/gulp.js']
npm ERR! errno: 50,
npm ERR! code: 'EPERM',
npm ERR! path: '/my/projectnode_modules/gulp/bin/gulp.js' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Linux 3.2.0-4-amd64
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "link" "gulp"
npm ERR! cwd /raid5/workspaces/jgr/aktivglueck-laravel
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! path /my/projectnode_modules/gulp/bin/gulp.js
npm ERR! code EPERM
npm ERR! errno 50
npm ERR! stack Error: EPERM, chmod '/my/projectnode_modules/gulp/bin/gulp.js'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /my/projectnpm-debug.log
npm ERR! not ok code 0
With
sudo npm link gulp
everything works fine.
What I want to know is: Why does npm link need admin permissions? In my understanding I am creating a link inside my project folder where I have full permissions - so what does it do on the global system?
I believe npm link creates a symlink to the current directory in wherever your globally installed node packages are. See here.
If you don't have write rights to that path (you can check with npm config get prefix) you'll get the error you see there.
To avoid having to sudo global installs/links, you could change the ownership/rights of that directory.

nvm installed node and npm, symlink issue when installing local browserify

Today I have installed the latest version of node through nvm on Linux Mint (Ubuntu 13.10).
Thanks to nvm, I now don't have to use the sudo command with npm - which has solved problems with a few packages.
$ node -v
v0.10.29
$ npm -v
1.4.14
However when entering this command:
npm install browserify --save-dev
I now get the following error:
npm ERR! Error: EACCES, symlink '../browserify/bin/cmd.js'
npm ERR! { [Error: EACCES, symlink '../browserify/bin/cmd.js'] errno: 3, code: 'EACCES', path: '../browserify/bin/cmd.js' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Linux 3.11.0-12-generic
npm ERR! command "/home/dave/.nvm/v0.10.29/bin/node" "/home/dave/.nvm/v0.10.29/bin/npm" "install" "browserify" "--save-dev"
npm ERR! cwd /var/www/100mondays-l4.2/frontend
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! path ../browserify/bin/cmd.js
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, symlink '../browserify/bin/cmd.js'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /var/www/100mondays-l4.2/frontend/npm-debug.log
npm ERR! not ok code 0
When I try to comply with the error advice:
$ sudo npm install browserify --save-dev
sudo: npm: command not found
I have been able to install other modules with npm - globally and locally - with no issues. So my guess is the error is to do with symlinks? My local site is in /var/www/ but my node/npm installation is in ~/.nvm/, and my home folder doesn't follow symlinks? However I'm not a server/Linux expert so could be off the mark.
This works fine:
npm install browserify -g
Any help greatly received.
Adding browserify to my package.json manually and using npm install from the project root solved my issue. Not really sure why.

Why can't i npm install nodemon or supervisor on OSX 10.8.4?

I'm just trying to install nodemon or supervisor using terminal, and I keep getting this error which I don't understand. I tried running as the administrator with sudo npm install supervisor -g which seemed to work, but than didn't when i deleted/added some js code. Any ideas?
Squirrels-MacBook-Air:lesson7_examples Squirrel$ npm install nodemon -g
npm http GET https://registry.npmjs.org/nodemon
npm http 304 https://registry.npmjs.org/nodemon
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/nodemon'
npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/nodemon']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/nodemon',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/nodemon',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR! '/usr/local/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 Darwin 12.4.1
npm ERR! command "node" "/usr/local/bin/npm" "install" "nodemon" "-g"
npm ERR! cwd /Users/Squirrel/Documents/Code/Memry/Memry_Mongoose
npm ERR! node -v v0.10.21
npm ERR! npm -v 1.3.11
npm ERR! path /usr/local/lib/node_modules/nodemon
npm ERR! fstream_path /usr/local/lib/node_modules/nodemon
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/local/lib/node_modules/nodemon'
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/local/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! /Users/Squirrel/Documents/Code/Memry/Memry_Mongoose/npm-debug.log
npm ERR! not ok code 0
Squirrels-MacBook-Air:lesson7_examples Squirrel$
P.S. I'm running this on a pre-existing template and my dependencies are
"dependencies": {
"mongoose": "~3.6.15",
"express": "~3.3.4",
"jade": "~0.34.1",
"email-validator": "~0.1.2"
}
When I tried sudo this is what happened:
sudo npm install supervisor -g --save
Password:
npm http GET https://registry.npmjs.org/supervisor
npm http 304 https://registry.npmjs.org/supervisor
/usr/local/bin/node-supervisor -> /usr/local/lib/node_modules/supervisor/lib/cli-wrapper.js
/usr/local/bin/supervisor -> /usr/local/lib/node_modules/supervisor/lib/cli-wrapper.js
supervisor#0.5.6 /usr/local/lib/node_modules/supervisor
Which seemed to work. But than in the application code I began to add and delete javascript and click save, yet the effects wouldn't take place unless I restarted the server within terminal.
Late to the party, but it is important to note that you should avoid using sudo when npm installing. It is a huge security risk to sudo npm install as you are giving arbitrary scripts root access to your machine.
Instead you should make yourself the owner of the directories in which the NPM
sudo chown -R $USER /usr/local
and then
sudo chown -R $USER ~/.npm
Now you should be able to run the commands without sudo:
npm install supervisor -g --save
You're encountering an EACCES error, which means you don't have the rights to create a directory in /usr/local/lib/node_modules/nodemon as a standard user in Mac OS X.
There are two solutions:
Run the same command as a superuser, using sudo. The package will be installed in /usr/local/lib/node_modules.
Change npm's settings to install all of your global packages into one of your private folders, that your user has ownership of. See this relevant answer that explains step-by-step the process.
I know I'm late to the question, but you should check out nvm (node's answer to rbenv or virtualenv).
Install:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash
Then add . ~/.nvm/nvm.sh to your ~/.bashrc, ~/.profile, or ~/.zshrc
Usage:
If you wanted to use version 0.10, run nvm install 0.12.7 (or nvm install stable), then nvm use 0.12.7.
Install your libs, EACCESS error-free, and go to town. npm install -g supervisor works just fine!
To load a specific version default in new tabs, use the command nvm alias default 0.12.7

Resources