Created
February 8, 2013 06:43
-
-
Save chakrit/4737131 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nvmcp $old_version | |
# | |
# Copy all globally-installed npm packages from $old_version to `default` version. | |
# Had to roll this since nvm copy-packages doesn't quite work. | |
nvmcp () { | |
nvm use $1 | |
npm ls -g --parseable 2> /dev/null \ | |
| grep -E "node_modules" \ | |
| grep -Ev "node_modules.+node_modules" \ | |
| sed -Ele "s/^.+node_modules\/(.+)/\\1/g" \ | |
> /tmp/nvmx_modules | |
echo "Found these packages:" | |
cat /tmp/nvmx_modules | |
nvm use default | |
npm install -g `cat /tmp/nvmx_modules` | |
rm /tmp/nvmx_modules | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment