Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save npm list to file

Tags:

node.js

npm

I often move between computers when developing things. With npm and my package.json it means, or so I thought, everything would be the same when checked out. At least on the same major version ~4.0.0 or example.

However on my fast PC at work I get compile times of 11s compared to, at home, 1.2s.

I'd like to save out npm list to file so I can run a compare at home.

npm list --save npmlist.txt //for example
like image 290
Jamie Hutber Avatar asked Mar 17 '15 16:03

Jamie Hutber


2 Answers

If you have problems with npm shrinkwrap, on windows you can use this:

npm list -json > npmlist.json

And for global packages

npm list -json -g > npmlist.json
like image 109
Alex Avatar answered Oct 01 '22 18:10

Alex


You can use npm shrinkwrap to generate a npm-shrinkwrap.json file. This file contains the exact versions of npm modules you have installed at that moment, recursively (so also modules of modules and so on). As long as that file sits in the root of your project, running npm install will install exactly those versions.

You can generate one on either pc to compare, or commit/copy the version generated on one pc to install the same versions of npm modules on the other.

like image 30
Jasper Woudenberg Avatar answered Oct 01 '22 19:10

Jasper Woudenberg