Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export import npm global packages

Tags:

npm

I would like to reinstall npm from scratch. I wish to reinstall the packages already installed globally in npm, after the reinstall. What would be the safest (and non-manual) way to export and import the globally installed modules?

Implementation note: my old npm also required sudo for global installations, so I'm not really looking to reuse the same directory, rather, to have the new npm install the same package list as the old one had.

like image 986
matanster Avatar asked Sep 17 '15 10:09

matanster


1 Answers

I use this on Windows with PowerShell:

[string]::join(" ", ((npm ls -g --depth=0) | select -skip 1 | select -skiplast 1 | % { $_.remove(0,4) }))

like image 126
Ingo Karstein Avatar answered Sep 24 '22 04:09

Ingo Karstein