What am I doing wrong when setting up my packages ? Is there any way to speed this up ?
packages.json :
{
"name": "testing node",
"version": "0.0.0",
"description": "",
"main": "app.config.js",
"dependencies": {
"babel-core": "^6.17.0",
"babel-loader": "^6.2.0",
"babel-plugin-add-module-exports": "^0.1.2",
"babel-plugin-react-html-attrs": "^2.0.0",
"babel-plugin-transform-class-properties": "^6.3.13",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"react": "^0.14.6",
"react-dom": "^0.14.6",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.14.1",
"mysql": "*"
},
"devDependencies": {},
"scripts": {
"dev": "webpack-dev-server --content-base src --inline --hot",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
When inside the folder if I run
npm install
I get the following which can take hours to fully setup:
This is not a general computing or hardware issue. Comparative speeds are below :
haversine
to calculate all distances on over 1 million records in a non-index mysql table takes significantly less time. (computational)I suspect there is something wrong with my packages.json
or the command I am running npm install
. From the image, it seems there are numerous attempts to retrieve the same file. Possibly there is a way to force npm
to retrieve from a more stable mirror ? Possible the mirror selection it uses by default is wonky ? Just some suggestions -- I don't know the specific cause which is why I am asking.
This problem also occurs on my Linode, Digital Ocean, and VULTR boxes -- so I suspect it is something specific with npm
, the way I am using (something missing), or my packages.json
.
This link helped me boost npm installs. Force npm to use http over https and disable progress display.
I was having this problem and none of the solutions in SO helped. I figured it out so I am posting it here in case any one else has a similar issue.
I was trying to run npm i on an amazon instance. The problem ended up being the fact that linux only opens up a certain amount of ports, and when npm i runs, it opens like more than a thousand connects to the registry to download all the packages. So it would work but then just freeze for like 15 minutes. Then the timeout would occur and it would eventually move on to another port. So in my security group in AWS I added a rule for All TCP at 0.0.0.0/0 in outgoing only, letting npm open as many outgoing connections as it likes and that fixed it.
I had the same problem on Debian, yarn was the solution for me.
I see from your screenshot that you are using WSL on Windows. And, with Windows, comes virus scanners, and virus scanning can make NPM install very slow!
Adding an exemption or disabling virus scanning during install can greatly speed it up, but potentially this is undesirable given the possibility of malicious NPM packages
One link suggests triple install time https://ikriv.com/blog/?p=2174
I have not profiled extensively myself though
One thing I noticed is, if you are working in new project(folder) you have to reconfigure proxy setting for the particular path
Cd(change terminal window path to the destination folder.
npm config set proxy http://(ip address):(port)
npm config set https-proxy http://(ip address):(port)
npm install -g @angular/cli
install nvm and try it should help, use below command:-
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
we also have had similar problems (we're behind a corporate proxy). changing to yarn at least on our jenkins builds made a huge difference.
there are some minor differences in the results between "npm install" and "yarn install" - but nothing that hurts us.
I had similar problems. I was also confused by some solutions leaving me with different versions displaying for different users. If you have any problems at all, I would first check every account your using any implementation of node
Finally, this solution appears to solve this issue 100%, giving me the confidence that my versions were universal no matter what user privileges I wanted to use:
sudo yum update
sudo yum install build-essential checkinstall libssl-dev
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.35.1/install.sh | bash
(sudo) nvm --version
(sudo) nvm ls-remote
(sudo) nvm install [version.number]
If you're still having a problem, next try looking inside your /usr/local/bin directory. If you find either a large binary document named node or a folder named npm, delete them.
rm /usr/local/bin/node
rm -r /usr/local/bin/npm
Personally, before I deleted those, two of my user accounts were using the latest version of node/npm installed correctly via nvm, while a third account of mine remained stubborn by still using a far older installation of both node and npm apparently located inside my /usr/local/bin/ directory. As soon as I deleted both of them with the two above commands, that problematic user account implicitly began running the correct installation, having all three accounts mutually the intended versions.
(Implemented while using Centos 7 Blank x64. Some source code used above was originally supplied by 'phoenixNAP Global IT services' 1)
Problem: NPM does not perform well if you do not keep it up to date. However, bleeding edge versions have been broken for me in the past.
Solution: As Kraang mentioned, use node version manager nvm, with its --lts flag
Install it:
curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
Then use this often to upgrade to the latest "long-term support" version of NPM:
nvm install --lts
Big caveat: you'll likely have to reinstall all packages when you get a new npm version.
I am using Linux and have nvm
and working with more than 7 version of node
As of my experience I experienced the same situation with my latest project (actually not hours but minutes as I can't wait hours because of hourly project :))
Disclaimer: don't try below option until you know how cache clean works
npm cache clean --force
and then all working fine for me so it's looks like sometimes npm's cache gets confused with different versions of Node.
Official documentation of Npm cache can be found here
One of the simple solution to speed up your npm install is to spin up a high powered machine on AWS and use that to compile your project and ship the code back to you.
I was experimenting with it and I found that there was a very high decrease in the time to run npm install. I found a tool to execute the above command easily https://stormyapp.com
I was having the same problem, i am on the nodejs version: 8.9.4
and npm version: 5.6.0
.
I tried a lot solutions online, including the ones on this post, none worked for me, then i found about yarn package manager which solved the problem for me, so if all fails, i think "yarn" is worth checking out.
EDIT:
It seems npm has problems when it is outdated, updating it has helped me as well.
Source: Stackoverflow.com