Reputation: 6236
The day I have to start a web project, I cringe. I use yeoman
and gulp-angular
generator for setting up my workflow. There hasn't been a time when npm install
's succeeded without failing once.
Also, it take anything from a good 3-4 hours on my average internet connection for a project to be set up. Doesn't it defeat the whole purpose of tooling? I end up spending more time waiting than I would do without npm
. Also it installs similar packages (~120MB of bloat) for every project.
I know that there are tools like npm_lazy
and caching and stuff, but these just make front-end tooling more complex than it is.
What makes npm
so inefficient?
Upvotes: 1
Views: 3164
Reputation: 1
npm is not inefficient it your connection that is not good enough, you can switch to a Morden Wi-Fi internet connection, I have experience this more than 6 time when installing Next.js
, Rect
, vite@latest
, but anytime I switch my wi-fi connection it will install them within 1 minute which take at least 2-3hours before it pops up timeout error without not installing.
Upvotes: -2
Reputation: 28345
I also feel your pain ... If you are actively developing a new nodejs project where you wish to always use the latest release of all your upstream npm packages then avoid mentioning any dependencies in your package.json file until your are ready to distribute. This slowdown we experience is due to unnecessarily storing these upstream packages inside your project directory in dir /node_modules/ which is not useful until your distribute your app.
Here I mention no up stream packages in this package.json file :
{
... other tags here ...
"dependencies" : {
}
}
Also install your project's upstream npm packages globally using the -g flag as in :
npm install -g some_cool_package
so these packages are usable by your project yet do not live inside its root dir bogging down your productivity. Concomitantly, do not issue
npm install
while inside your nodejs project root dir since all your upstream npm packages live in the global install directory as defined by the environment variable NODE_PATH
echo $NODE_PATH
which has a value akin to
/home/stens/node-v5.3.0/lib/node_modules
That is the global npm package storage location which gets populated when you install npm packages using the -g flag . That $NODE_PATH will get bloated with all your upstream npm packages instead of getting stored inside your nodejs app /node_modules/ directory
Develop away in this mode free of this baggage ... when you are ready to distribute then do populate your package.json file with your upstream npm packages and issue your npm install to populate the dir /node_modules/ ... of course add your node_modules to your .gitignore so that dir is not sent into git
You can also do this to your existing nodejs apps by emptying out the "dependencies" tag of your package.json file and deleting directory /node_modules/ ... until your are ready to distribute
Upvotes: 2