NPM install is not working [code 128] - javascript

NPM is not working it's giving permission denied error. Here is the full log:
npm ERR! code 128
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b master git://github.com/jonschlinkert/resolve-file.git /root/.npm/_cacache/tmp/git-clone-8b5c9e7d
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-8b5c9e7d': Permission denied
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-04-11T06_46_34_324Z-debug.log
root#ip-172-31-15-60:/var/www/html/itracker# npm install request
npm ERR! code 128
npm ERR! Command failed: /usr/bin/git clone --depth=1 -q -b master git://github.com/jonschlinkert/resolve-file.git /root/.npm/_cacache/tmp/git-clone-77c3de2c
npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-77c3de2c': Permission denied
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-04-11T06_47_05_916Z-debug.log
What i tried:
completely removed node and NPM and installed.
sudo chown -R $(whoami) ~/.npm
by following the answer from here: npm throws error without sudo
Note:
I tried to install globally is working. But installing locally is not working.
I tried both sudo and normal user.

try sudo npm install even if you are working on sudo user

Use the latest npm
npm install -g npm

Related

error when installing nodemon on Ubuntu 18.04

when i install nodemon with
sudo npm i --save-dev nodemon
i get the following error message:
npm ERR! path /home/dominikpatera/Dropbox/Projekty/Fytwa/server/node_modules/npm/node_modules/abbrev
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/home/dominikpatera/Dropbox/Projekty/Fytwa/server/node_modules/npm/node_modules/abbrev' -> '/home/dominikpatera/Dropbox/Projekty/Fytwa/server/node_modules/npm/node_modules/.abbrev.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/dominikpatera/.npm/_logs/2018-07-11T09_45_21_545Z-debug.log
can you help me fix it?
Open Terminal and type:
sudo npm install -g nodemon
then
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
you will get an output similar to:
fs.inotify.max_user_watches=524288
fs.inotify.max_user_watches = 524288
After that your nodemon will perfectly work.
At first make sure that on your terminal, you are working on the correct project. you can check this by typing ls and then hit enter.
Then give the command to install nodemon. From the official website of nodemon, we found that, we have to write npm install -g nodemon
But if you fall in problem here, then write this-
sudo npm install -g nodemon

Command not found

Been struggling to get my first vue project started and was looking for some help.
I have both npm and node updated on my system but continually keep falling to the same issue.
My steps:
1.) npm install
Terminal Response:
npm WARN mbasile#1.0.0 No description
up to date in 0.095s
2.) npm install vue
Terminal Response:
npm WARN mbasile#1.0.0 No description
+ vue#2.5.16
updated 1 package in 0.951s
Here's where things get funky?
3.) npm install -g #vue/cli
Terminal Response:
npm ERR! path /Users/mbasile/.npm-global/lib/node_modules//node_modules/.bin
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rmdir
npm ERR! Error: EACCES: permission denied, rmdir '/Users/mbasile/.npm-global/lib/node_modules//node_modules/.bin'
npm ERR! { Error: EACCES: permission denied, rmdir '/Users/mbasile/.npm-global/lib/node_modules//node_modules/.bin'
npm ERR! cause:
npm ERR! { Error: EACCES: permission denied, rmdir '/Users/mbasile/.npm-global/lib/node_modules//node_modules/.bin'
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rmdir',
npm ERR! path: '/Users/mbasile/.npm-global/lib/node_modules//node_modules/.bin' },
npm ERR! stack: 'Error: EACCES: permission denied, rmdir '/Users/mbasile/.npm-global/lib/node_modules//node_modules/.bin'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rmdir',
npm ERR! path: '/Users/mbasile/.npm-global/lib/node_modules//node_modules/.bin' }
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/mbasile/.npm/_logs/2018-05-09T17_53_06_030Z-debug.log
So given this response I run
4.) sudo npm install -g #vue/cli
Terminal Response:
/Users/mbasile/.npm-global/bin/vue -> /Users/mbasile/.npm-global/lib/node_modules//bin/vue.js
+ #3.0.0-beta.9
updated 1 package in 6.597s
5.) vue create vue-project
Terminal Response:
-bash: vue: command not found
Leaving me a bit puzzled and confused here, but any help/response would be appreciated.
I had this problem too and it was a little bit tricky to find a solution so I'll describe all the steps that helped me find a solution.
It's resolving a general problem with the wrong path for global packages in npm or missing path in shell variable $PATH.
Fix for macOS Mojave but should work on all UNIX systems
First of all, after installing the package globally npm will show you where a new package is installed.
$ npm i -g #vue/cli
/usr/local/Cellar/node/9.5.0/bin/vue -> /usr/local/Cellar/node/9.5.0/lib/node_modules/#vue/cli/bin/vue.js
We can also check it in the npm config.
$ npm config get prefix
/usr/local/Cellar/node/9.5.0
So if after the global installation your terminal couldn't recognize the command it's probably missing in your shell variable $PATH. You can easily check it.
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
As we can see, the path from npm config isn't present in the shell variable $PATH.
Now we have two options to fix it.
1. First option - change npm config.
$ npm config set prefix '/usr/local'
$ npm config get prefix
/usr/local
After we changed the path in the config we will have to reinstall the desired package.
$ npm i -g #vue/cli
2. Second option - add path from npm config to shell $PATH
$ export PATH=$PATH:/usr/local/Cellar/node/9.5.0
In this case, we don't need to install the package again.
Regardless of the selected option, we can now control if everything works.
$ vue --version
3.0.5
Maybe it is something wrong with npm
I recommend you,first list all global npm packages to see if vue is installed with the command: npm list -g --depth=0
Then if vue is installed but again you get error try to delete vue with the command: npm uninstall -g nameOfPackage
Finally do it again from scratch: npm install -g #vue/cli and to create new project,navigate to directory you want to create the project and execute: vue create nameOfProject
What are you trying to do?
npm install -g #vue/cli
This is the command you should run on terminal to globally (-g) install vue command line interface.
After that you can do vue create vue-project

npm config permission error

I am having permission problems with the npm config command. It seems that for some reason it is trying to change the owner of my ~/.npmrc file. When running npm config set color false, I get the following error:
npm ERR! Error: EPERM, chown '/home/bamboo/.npmrc'
npm ERR! { [Error: EPERM, chown '/home/bamboo/.npmrc'] errno: 50, code: 'EPERM', path: '/home/bamboo/.npmrc' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Linux 3.13.0-32-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "config" "set" "color" "false"
npm ERR! cwd /home/bamboo
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! path /home/bamboo/.npmrc
npm ERR! code EPERM
npm ERR! errno 50
npm ERR! stack Error: EPERM, chown '/home/bamboo/.npmrc'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/bamboo/npm-debug.log
npm ERR! not ok code 0
The file .npmrc has the right permissions and I can edit it manually but I need to do it from the npm config command since it is part of an automated build. I can't seem to find valuable information on that matter. I set the prefix to a directory I own and can install globally without any problem but can't run configure! I am running Ubuntu 14.04.
Does anybody have some ideas?
I had the same problem.
https://github.com/npm/npm/issues/7563
Turns out changing from sudo su to sudo su - when starting the bamboo agent process solved the problem.
Got this problem once.
The .npm directory does not have sufficient permissions. Run the following command:
sudo chown -R $(whoami) ~/.npm

Yeoman Javascript error involving 'mkdir'

I'm setting up a Meanjs instance with a Yeoman generator. When I do 'sudo yo meanjs' everything works fine until it looks like it is trying to make a directory and it fails, any ideas on what is going on here?
SOLINK_MODULE(target) Release/kerberos.node: Finished
> bson#0.2.5 install /Users/xxx/Documents/mean/node_modules/connect-
mongo/node_modules/mongodb/node_modules/bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)
CXX(target) Release/obj.target/bson/ext/bson.o
SOLINK_MODULE(target) Release/bson.node
SOLINK_MODULE(target) Release/bson.node: Finished
npm ERR! Error: EACCES, mkdir '/Users/xxx/.npm/uglify-js/2.4.15'
npm ERR! { [Error: EACCES, mkdir '/Users/xxx/.npm/uglify-js/2.4.15']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/Users/xxx/.npm/uglify-js/2.4.15',
npm ERR! parent: 'grunt-contrib-uglify' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 13.4.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/xxx/Documents/mean
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! path /Users/xxx/.npm/uglify-js/2.4.15
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/Users/xxx/.npm/uglify-js/2.4.15'
npm ERR! not ok code 0
That is a pretty common error.
Yeoman is running the following:
bower install & npm install
Bower install succeeded, however NPM install is failing because of user permissions. Just run:
sudo npm install
The ZenCoder's answer is spot on, but if you want to permanently fix this permissions error, you can follow the tutorial at: https://docs.npmjs.com/getting-started/fixing-npm-permissions
Since you're on a Mac, you could actually avoid npm permissions errors altogether by just installing node instead via homebrew:
brew install node (this will install npm too)
Homebrew installs programs to a directory that doesn't require sudo for write, so you can npm install -g <whatever> freely without it.

TypeError: Request path contains unescaped characters

I try to install node.js modules using:
npm install express
but I get this error:
npm http GET https://registry.npmjs.org/express
npm ERR! TypeError: Request path contains unescaped characters.
npm ERR! at Agent.request (_http_agent.js:264:11)
npm ERR! at TunnelingAgent.exports.request (http.js:52:22)
npm ERR! at TunnelingAgent.createSocket (/usr/local/lib/node_modules/npm/node_modules/request/node_modules/tunnel-agent/index.js:117:25)
npm ERR! at TunnelingAgent.createSecureSocket [as createSocket] (/usr/local/lib/node_modules/npm/node_modules/request/node_modules/tunnel-agent/index.js:184:41)
npm ERR! at TunnelingAgent.addRequest (/usr/local/lib/node_modules/npm/node_modules/request/node_modules/tunnel-agent/index.js:80:8)
npm ERR! at new ClientRequest (_http_client.js:112:16)
npm ERR! at Agent.request (_http_agent.js:279:10)
npm ERR! at Object.exports.request (https.js:130:22)
npm ERR! at Request.start (/usr/local/lib/node_modules/npm/node_modules/request/index.js:594:30)
npm ERR! at Request.end (/usr/local/lib/node_modules/npm/node_modules/request/index.js:1186:28)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR! System Linux 3.6.11-7.fc16.x86_64
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "express"
npm ERR! cwd /usr/local/src/node
npm ERR! node -v v0.11.5-pre
npm ERR! npm -v 1.3.5
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /usr/local/src/node/npm-debug.log
npm ERR! not ok code 0
May be happening I use a proxy I set it up this way to allow downloads from ips outside my network
export https_proxy='http://172.21.0.12:3128'
I hope you can help me
Set proxy from commandline.
npm config set proxy http://proxydomain:port/
If error occur yet, additional try next.
npm config set registry http://registry.npmjs.org/
These work for me.
(ref http://sushichop.blogspot.jp/2013/01/npm-install.html)
Though late enough, I've bumped into this too after updating nodejs (to 4.1.1) and npm (to something like 1.4.x) on Linux.
I've tried the suggested solution, but changing the registry entry did not help in all cases.
Lastly, having decided to reinstall npm, I found this update source [on npm github][1]
curl -L https://www.npmjs.org/install.sh | sh
which updated my npm to 3.3.8 and all related package installation troubles have been blown away.

Categories

Resources