npm not installing tar package from cache when forced - node.js

I'm using Node v5.0.0 and npm v3.3.6 and running into a very isolated issue with he tar package. Due to corporate firewalls I was forced to clone the Git repository and install it from that
My problem is that despite forcing npm to install packages from the cache, tar is the only package that insists on downloading it from npm's registry.
$ npm install tar#2.2.1 --verbose --cache-min=999999999999
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli 'install',
npm verb cli 'tar#2.2.1',
npm verb cli '--verbose',
npm verb cli '--cache-min=999999999999' ]
npm info using npm#3.3.6
npm info using node#v5.0.0
npm verb get http://registry.npmjs.org/tar not expired, no request
npm verb cache add spec tar#2.2.1
npm verb addNamed "2.2.1" is a plain semver version for tar
npm verb addNameVersion registry:http://registry.npmjs.org/tar not in flight; fetching
npm verb get http://registry.npmjs.org/tar not expired, no request
npm verb addRemoteTarball http://registry.npmjs.org/tar/-/tar-2.2.1.tgz not in flight; adding
npm verb addRemoteTarball [ 'http://registry.npmjs.org/tar/-/tar-2.2.1.tgz',
npm verb addRemoteTarball '8e4d2a256c0e2185c6b18ad694aec968b83cb1d1' ]
npm info retry fetch attempt 1 at 8:38:23 AM
npm info attempt registry request try #1 at 8:38:23 AM
npm http fetch GET http://registry.npmjs.org/tar/-/tar-2.2.1.tgz
npm verb request id b8672d43f7b2c569
npm http fetch 503 http://registry.npmjs.org/tar/-/tar-2.2.1.tgz
npm info retry will retry, error on last attempt: Error: server error 503
I've double checked my cache and can see that tar v2.2.1 is in fact present and functional.
$ npm cache list | grep 'tar\\2.2.1'
~\AppData\Roaming\npm-cache\tar\2.2.1
~\AppData\Roaming\npm-cache\tar\2.2.1\package
~\AppData\Roaming\npm-cache\tar\2.2.1\package.tgz
~\AppData\Roaming\npm-cache\tar\2.2.1\package\package.json
For what it's worth, I'm able to overcome this issue by simply adding the project's Git repository in my dependencies folder and use npm install deps/node-tar before doing npm install. Still doesn't explain the problem at hand, however.

Related

getting "Error: EINVAL: invalid argument, read" for "npm install --save-dev eslint --verbose"

Any ideas/assistance here re how to get "npm install --save-dev eslint --verbose" working. I keep getting:
Error: EINVAL: invalid argument, read
I've setup up a new react-native project:
react-native init gcLists
E:\gcLists>npm -v
5.5.1
E:\gcLists>yarn -v
1.2.1
E:\gcLists>react-native -v
react-native-cli: 2.0.1
react-native: 0.49.5
npm install --save-dev eslint --verbose
Last part of the log:
npm http fetch GET 304 https://registry.npmjs.org/slice-ansi 104ms (from cache)
npm verb correctMkdir D:\Users\greg\AppData\Roaming\npm-cache\_locks correctMkdir not in flight; initializing
npm verb lock using D:\Users\greg\AppData\Roaming\npm-cache\_locks\staging-255cd84f0d76b150.lock for E:\gcLists\node_modules\.staging
npm info lifecycle semver#5.4.1~preuninstall: semver#5.4.1
npm info lifecycle semver#5.4.1~uninstall: semver#5.4.1
npm verb unbuild rmStuff semver#5.4.1 from E:\gcLists\node_modules
npm verb unlock done using D:\Users\greg\AppData\Roaming\npm-cache\_locks\staging-255cd84f0d76b150.lock for E:\gcLists\node_modules\.staging
npm verb stack Error: EINVAL: invalid argument, read
npm verb stack at D:\Users\greg\AppData\Roaming\npm\node_modules\npm\lib\utils\gently-rm.js:275:7
npm verb stack at D:\Users\greg\AppData\Roaming\npm\node_modules\npm\node_modules\iferr\index.js:13:50
npm verb stack at D:\Users\greg\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\polyfills.js:287:18
npm verb stack at FSReqWrap.oncomplete (fs.js:154:5)
npm verb cwd E:\gcLists
npm verb Windows_NT 6.1.7601
npm verb argv "C:\\Program Files\\nodejs\\node.exe" "D:\\Users\\greg\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save-dev" "eslint" "--verbose"
npm verb node v8.7.0
npm verb npm v5.5.1
npm ERR! code EINVAL
npm ERR! EINVAL: invalid argument, read
npm verb exit [ 1, true ]
npm ERR! A complete log of this run can be found in:
npm ERR! D:\Users\greg\AppData\Roaming\npm-cache\_logs\2017-11-03T02_38_08_842Z-debug.log
Notes:
On Windows 7
UPDATE:
* Results of npm install --save-dev eslint --verbose may be found here.
Since you are using drive letter E:, you might be on a portable drive. I had the same problem using an USB-Stick formatted on FAT32. I solved it reformatting to NTFS.
What helped me was to also delete my package-lock.json file.
rm -rf node_modules package-lock.json
npm i
Sometimes some packages have issues with npm. This could be base on combination of OS/package version/node version/npm version compatibility issue.
In such cases best thing is to do is try and use some other package manager. Try this with yarn
yarn add eslint
Same problem happened to me and what i did was deleting the whole node_modules folder and run npm install again. It fixed the error.
The reason was in the initial npm install it was closed in the middle by me which crashed some files.
Try cleaning the npm cache:
npm cache clean
Then try again.
I was getting the error when I did npm update so i deleted some npm outdated node_modules and ran npm update again and it worked.
yarn upgrade also fixed the thing.

package.json for globally installed packages

I'm trying to update my nuclide-server. The output of sudo npm update -g nuclide --verbose is:
$ sudo npm update -g --dev nuclide --verbose
npm info it worked if it ends with ok
npm verb cli [ '/usr/bin/nodejs',
npm verb cli '/usr/bin/npm',
npm verb cli 'update',
npm verb cli '-g',
npm verb cli '--dev',
npm verb cli 'nuclide',
npm verb cli '--verbose' ]
npm info using npm#4.2.0
npm info using node#v7.9.0
npm verb request uri https://registry.npmjs.org/nuclide
npm verb request no auth needed
npm info attempt registry request try #1 at 11:02:17 AM
npm verb request id bf1180b825d1a807
npm verb etag W/"590a3387-6633d"
npm verb lastModified Wed, 03 May 2017 19:46:15 GMT
npm http request GET https://registry.npmjs.org/nuclide
npm http 304 https://registry.npmjs.org/nuclide
npm verb headers { date: 'Fri, 12 May 2017 11:02:17 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers 'cache-control': 'max-age=300',
npm verb headers etag: 'W/"590a3387-6633d"',
npm verb headers age: '132',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-syd1625-SYD',
npm verb headers 'x-cache': 'HIT',
npm verb headers 'x-cache-hits': '1',
npm verb headers 'x-timer': 'S1494586937.425880,VS0,VE0',
npm verb headers vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/nuclide from cache
npm verb get saving nuclide to /home/daniel/.npm/registry.npmjs.org/nuclide/.cache.json
npm verb correctMkdir /home/daniel/.npm correctMkdir not in flight; initializing
npm verb outdated not updating nuclide because it's currently at the maximum version that matches its specified semver range
npm verb exit [ 0, true ]
npm info ok
Searching Google hasn't turned anything up to help this, they all refer to a package.json and changing some stuff in there, but I don't have a package.json (probably because I'm installing this globally). How do I find the config or do something else to just allow me to update my nuclide package?
System info:
Ubuntu 16.04
npm version: 4.2.0
node version: v7.9.0
Current nuclide version: 217
The package.json config your looking for is wherever you installed node orginally, on windows it's at /usr/local. On unix systems it can be found via usr/local/lib/node or /usr/local/lib/node_modules.
you can alternatively run sudo npm root -g to find where your installtion.
Furthermore it can be found by following the links to the nodejs application which will take you to your installation folder. These links are made after a successful instillation.
Afterwhich you can remove the remove/update the dependancy within package.jsonand run npm i -g again.
Specifically on your version your installation folder is /usr/local/lib/node_modules.

NPM install hangs on loadRequestedDeps

When I download any package using NPM, it hangs on the last command "loadRequestedDeps." I've added my whole -verbose output to the end of this question for reference. It will just sit there until I cancel the command, and nothing will be installed and my package.json will not be updated.
What could the issue be? I've looked around but haven't found out how to fix my particular problem.
Here's some info:
OS is Windows 10
Node version is 6.9.1
NPM version is 3.10.8
My CPU maxes out at 100% whenever I run NPM install. Could that be the issue itself? I used to be able to use NPM install on this computer, however.
Thanks for anyone who can help. The verbose output is below.
npm info it worked if it ends with ok
npm info using npm#3.10.8
npm info using node#v6.9.1
npm info ok
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli 'install',
npm verb cli 'moment',
npm verb cli '--save',
npm verb cli '-verbose' ]
npm info using npm#3.10.8
npm info using node#v6.9.1
npm verb request uri https://registry.npmjs.org/moment
npm verb request no auth needed
npm info attempt registry request try #1 at 11:19:11 AM
npm verb request id 6aa9ece5a04fcd33
npm verb etag W/"583b0871-194b0"
npm verb lastModified Sun, 27 Nov 2016 16:23:13 GMT
npm http request GET https://registry.npmjs.org/moment
npm http 304 https://registry.npmjs.org/moment
npm verb headers { date: 'Tue, 29 Nov 2016 19:19:02 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers 'cache-control': 'max-age=300',
npm verb headers etag: 'W/"583b0871-194b0"',
npm verb headers age: '11',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-sjc3136-SJC',
npm verb headers 'x-cache': 'HIT',
npm verb headers 'x-cache-hits': '1',
npm verb headers 'x-timer': 'S1480447142.653125,VS0,VE0',
npm verb headers vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/moment from cache
npm verb get saving moment to C:\Users\Zach\AppData\Roaming\npm-cache\registry.npmjs.org\moment\.cache.json
npm verb correctMkdir C:\Users\Zach\AppData\Roaming\npm-cache correctMkdir not in flight; initializing
npm verb cache add spec moment
npm verb addNamed "latest" is being treated as a dist-tag for moment
npm info addNameTag [ 'moment', 'latest' ]
npm verb addNameTag registry:https://registry.npmjs.org/moment not in flight; fetching
npm verb get https://registry.npmjs.org/moment not expired, no request
npm verb addNamed "2.17.0" is a plain semver version for moment
npm verb addRemoteTarball https://registry.npmjs.org/moment/-/moment-2.17.0.tgz not in flight; adding
npm verb addRemoteTarball [ 'https://registry.npmjs.org/moment/-/moment-2.17.0.tgz',
npm verb addRemoteTarball 'a4c292e02aac5ddefb29a6eed24f51938dd3b74f' ]
[ ..............] \ loadRequestedDeps: verb addRemoteTarball [ 'https://registry.npmjs.org/moment/-/moment-2.17.0.tgz',
I had this exact same issue, and it drove me crazy for about a day before I found these solutions.
After creating a new "tmp" folder in my C drive, and then changing the TEMP variable in my SYSTEM Environment variables to C:\tmp.
My "npm install" was still not working. (This action was based on Zach Nagatani's answer.)
I also had two TEMP variables defined in my USER Environment variables, and I had to delete one of the variables for my "npm install" to start working.
The above action was based on this post: https://github.com/npm/npm/issues/7590
I was so glad when I found it. Many thanks to you all.
Create new folder tmp in C: drive and go to the command prompt and type:
npm config set tmp C:/tmp
this is very general error ..
you have to debug with
npm install -verbose
it maybe
1) locked package.json
2) you are in private network and can't access outside world for some reason
3) cache is not good ( you may try with npm clear cache ) or ( cache verify ) or even changing its path (npm config set tmp )
npm cache verify did the trick for me!
EDIT
npm was stuck on loadAllDepsIntoIdealTree.
I couldn't figure out the issue, so it got me here. I saw #franckstifler's answer about npm cache clear and tried that, but the command was deprecated.
The shell itself instead suggested using npm cache verify. I did that and it worked! The garbage data in cache got swiped away and I rerun npm i --save-dev on my working folder and it worked.
Sometimes when you have tried several times to install a package, you need to clear your cache: npm cache clear. But yarn is a really better option compared to npm, it is fast and reliable. Install it with npm -i -g yarn and to download dependencies yarn add package_name from a package.json you use yarn install.
So, after trying to clear the npm cache, update my npm and node version, reinstalling npm and node, etc... I found that changing my Environment Variable TEMP to = C:\tmp worked. I'm not sure why. Any info would be nice.
I found the answer from this thread: npm install hangs on windows with multiple temp directories set
NOTE: I could use the method he uses (using the set command on my directory, but I had to do this with every new project. Changing the variable via System, Advanced System Settings, Environment Variables changed it globablly, so now I'm all good to go.
i tried googling nothing worked for me finally i found the fix by setting the environment varible
try use https://github.com/npm/npm/issues/10462
Finally Resolved The Problem(Wondering)
Change Both System And User TEMP Variable point to C:\temp and make a directory as C:\temp.
1.TEMP=C:\temp;
2.Make A Directory temp at C:\

npm install does not work when running npm install cordova

I am using Ionic framework to build hybrid apps. According to the official website, i need to get the version 4.2.4 of Node.js, which includes npm package manager. One of the dependencies needed by Ionic is cordova so that i run the following command to get it
C:\Users\ferrero>npm install -g cordova
After then, the console logs
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli 'prefix',
npm verb cli '-g' ]
npm info using npm#2.14.12
npm info using node#v4.2.4
npm verb exit [ 0, true ]
npm info ok
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm- cli.js',
npm verb cli 'install',
npm verb cli 'cordova' ]
npm info using npm#2.14.12
npm info using node#v4.2.4
npm verb config Skipping project config: C:\Users\ferrero/.npmrc.
(matches userconfig)
npm verb install initial load of C:\Users\ferrero\package.json
npm verb readDependencies loading dependencies from C:\Users\ferrero\package.json
npm verb cache add spec cordova
npm verb addNamed "latest" is being treated as a dist-tag for cordova
npm info addNameTag [ 'cordova', 'latest' ]
npm verb addNameTag registry:https://registry.npmjs.org/cordova not in flight; fetching
npm verb request uri https://registry.npmjs.org/cordova
npm verb request no auth needed
npm info attempt registry request try #1 at 16:47:06
npm verb request id 62f85abc5c5b7cd5
npm verb etag "6KQ69KRX02Y8MUJFT56H9DE6N"
npm http request GET https://registry.npmjs.org/cordova
npm info retry will retry, error on last attempt: Error: self signed certificate in certificate chain
As you can see from log, npm run version 2.14.12 and it complains that the cause is a self signed certificate - likely issued by https://registry.npmjs.org/cordova. So, to overcome this issue, I run
npm config set registry=http://registry.npmjs.org
And, after that (just the relevant part)
C:\Users\ferrero>npm install -g cordova
npm verb cache add spec cordova
npm verb addNamed "latest" is being treated as a dist-tag for cordova
npm info addNameTag [ 'cordova', 'latest' ]
npm verb addNameTag registry:http://registry.npmjs.org/cordova not in flight; fetching
npm verb request uri http://registry.npmjs.org/cordova
npm verb request no auth needed
npm info attempt registry request try #1 at 16:59:34
npm verb request id 359f93cb3aa8b76e
npm verb etag "6KQ69KRX02Y8MUJFT56H9DE6N"
npm http request GET http://registry.npmjs.org/cordova
npm http 304 http://registry.npmjs.org/cordova
npm verb headers {
date: 'Tue, 26 Jan 2016 18:59:34 GMT',
npm verb headers via: '1.1 varnish',
npm verb headers 'cache-control': 'max-age=300',
npm verb headers etag: '"6KQ69KRX02Y8MUJFT56H9DE6N"',
npm verb headers age: '263',
npm verb headers connection: 'keep-alive',
npm verb headers 'x-served-by': 'cache-atl6230-ATL',
npm verb headers 'x-cache': 'HIT',
npm verb headers 'x-cache-hits': '1',
npm verb headers 'x-timer': 'S1453834774.362657,VS0,VE1',
npm verb headers vary: 'Accept'
}
npm verb etag http://registry.npmjs.org/cordova from cache
npm verb get saving cordova to C:\Users\ferrero\AppData\Roaming\npm-cache\registry.npmjs.org\cordova\.cache.json
npm verb addNamed "5.4.1" is a plain semver version for cordova
npm verb addRemoteTarball http://registry.npmjs.org/cordova/-/cordova-5.4.1.tgz
not in flight; adding
npm verb addRemoteTarball [ 'http://registry.npmjs.org/cordova/-/cordova-5.4.1.tgz',
npm verb addRemoteTarball 'bc56bc1d3c5387a7926408212dfbce59002f9d76' ]
This time, it does not complain anything else. Instead, the loading indicator - a pipe character - keep running and running. So, what should i do in order to download such dependency ?
We seem to be looking at two distinct issues here.
The certificate error is likely due to an outbound SSL proxy. Someone, most likely your employer, is opening all SSL traffic on the way out. To fix it, you'll need to tell NPM that this certificate is okay by importing the CA certificate of the proxy in use.
npm config set cafile = "/the/certificate/file.pem"
You may also need to set the proxy address for npm as well:
npm config set proxy http://proxy.example.com:3128
npm config set https-proxy http://proxy.example.com:3128
The incompatibility with node 5.0 seems to have been fixed according to my research. The documentation just seems to be out of date.
The bug in Cordova which may have been the issue was a missing method in the Q promises library, which Cordova depends upon.
In November 2015 a user was able to use Ionic successfully with node 5.1.0.
Even i faced same issue while doing any npm install -g XXX command, it was resolved by npm config set strict-ssl false
Ok, I think the note about node 4 vs node 5 is from the old days of cordova 5.0 when there was a problem when installing cordova with node 5.
Since then they released cordova 5.4 and cordova 6 where there is no more issue with node 5.
I usually don't use ionic, but to be sure, with my fresh install of node v5.4.1, where I already was running cordova 5.4 (installed also with node 5.4.1), I:
installed cordova 6 : npm install -g cordova
installed ionic 1.7.13 : npm install -g ionic
created a ionic app : ionic start myApp tabs
run the app on an android device
cd myApp
cordova platform add android
ionic run android
And everything worked perfectly.
So I assume that you can safely try to install the latest version of node to build apps with ionic.
And maybe node 5.4.1 will solve the issue you face with node 4.2.4?
Problem here it that you are using self-signed certificate according to error self signed certificate in certificate chain.
If you want to fix the error here some info for you:
How to fix SSL certificate error when running Npm on Windows?
https://confluence.atlassian.com/display/SOURCETREEKB/Resolving+SSL+Self-Signed+Certificate+Errors
But if there is no way to deal with problem just set http registry(carry about config word)
npm config set registry http://registry.npmjs.org/
A similar thing happened to me before and what worked for me back then was.
First, uninstall node and npm.
Second, delete npm and npm-cache folders on C:\Users\yourname\AppData\Roaming.
And lastly, redownload and reinstall a fresh copy of node.js.
I'm not sure if this is gonna work on your case but hope this helps!!

npm hangs while trying to install gulp

UPDATED:
When I try to install any package with 'npm install', or any variant:
npm install gulp -g -verbose
npm install gulp -verbose
npm install gulp
npm install
npm install connect
I get the following output but it just hangs on the last line, never finishing the install:
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\\\node.exe',
npm verb cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli 'install',
npm verb cli 'gulp',
npm verb cli '-g',
npm verb cli '-verbose' ]
npm info using npm#2.5.1
npm info using node#v0.12.0
npm verb node symlink C:\Program Files\nodejs\\node.exe
npm verb cache add spec gulp
npm verb addNamed gulp#*
npm verb addNameRange registry:https://registry.npmjs.org/gulp not in flight; fetching
npm verb request uri https://registry.npmjs.org/gulp
npm verb request no auth needed
npm info attempt registry request try #1 at 4:09:05 PM
npm verb request id 77dfc5813704dba8
npm verb etag "EOZJDNUCAN683DXC55T2W1JVT"
npm http request GET https://registry.npmjs.org/gulp
npm http 304 https://registry.npmjs.org/gulp
npm verb etag https://registry.npmjs.org/gulp from cache
npm verb get saving gulp to C:\Users\iwiegand.TMI\AppData\Roaming\npm-cache\registry.npmjs.org\gulp\
.cache.json
npm verb addNamed gulp#3.8.11
npm verb addRemoteTarball https://registry.npmjs.org/gulp/-/gulp-3.8.11.tgz not in flight; adding
npm verb addRemoteTarball [ 'https://registry.npmjs.org/gulp/-/gulp-3.8.11.tgz',
npm verb addRemoteTarball 'd557e0a7283eb4136491969b0497767972f1d28a' ]
^CTerminate batch job (Y/N)?
It's definitely not https, since changing it to http yields the same result. It does this from any folder on my machine, no matter what package, or even just 'npm install'. I've restarted, resintalled node.js, etc. I'm on a Windows 8.1 machine and wishing I had a Mac.
The crazy thing is it HAS worked. I got Composer, Laravel and a bunch of other stuff installed just fine, then one day, it just started doing this. I have no idea what could be interfering. Checking the TaskManager, npm IS running with like 18% CPU usage the whole time it's "trying" to install.
Apparently I'm the only one on Earth with this problem. I've searched and searched on Google and nothing. I'm resorting to Facebook and Google groups. So far no suggestions from SO users have helped, although I very much appreciate the attempts.
I recently came across this problem and managed to fix it, on my own machine at least, by correcting my TEMP environment variable that had been mucked with by some other installer or npm package. I found an issue on github that was describing the exact same problem and I posted my discovery and resolution there.
Basically, someone had appended ;C:\Python27 to the end of my TEMP which was screwing up the unpacking of the npm module. So, maybe it's a long shot, but check it out and see if it works for you!

Resources