Skip to content

Instantly share code, notes, and snippets.

@davidnormo
Last active March 31, 2016 11:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidnormo/41f9391a5a64465315379646abb6e7a3 to your computer and use it in GitHub Desktop.
Save davidnormo/41f9391a5a64465315379646abb6e7a3 to your computer and use it in GitHub Desktop.
npm global export import

The following command will give you a string of all the npm packages and their versions that are currenctly globally installed.
Note: that this ignores packages installed from directories and picks only those installed via the npm registry.

$ npm ls -g --depth 0 | sed -e '1d' -e 's/└── //g' -e 's/├── //g' -e '/^.*->.*$/d' -e '/^$/d' | tr '\n' ' '

If you copy this string, you can then append it to the end of npm install -g to install all of the packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment