all-nvm - Run any NPM command (including install) in all versions of Node managed by NVM

jopen 8年前

all-nvm

Run any NPM command (including install) in all versions of Node managed by NVM

Inspiration

Part of my favorite little Node tools

If you are like me, you have probably several Node versions installed locally and managed using NVM. I also use bunch of small global tools like npm-quick-run, next-update, center-code. It is very frustrating to run

center <filename>  center: command not found  #$#$! I have not installed center-code in this Node version yet

I need to quickly install same tool in all Node versions.

Install

npm i -g all-nvm

Installs itseslf under several aliases: all-nvm, nvm-all and my favorite alias all. Make all-nvm available in all Node versions right after install

all npm i -g all-nvm

Use

With all-nvm it is simple to run the same command in all Node versions managed by NVM. For example, if you want to speed up NPM installs by removing the progress indicator

all npm set progress=false

Install a global tool as-a in all Node versions

all npm i -g as-a

Details

I was inspired by the command exec already available in NVM - it runs any command in the specified Node version. For example

nvm exec 4 node -v  Running node v4.2.2 (npm v3.7.2)  v4.2.2

Since NVM itself is a shell script, one has to play games in order to shell a command, for example to run nvm --version

sh -c '. ~/.nvm/nvm.sh && nvm --version'

and to run same command on a particular Node version

sh -c '. ~/.nvm/nvm.sh && nvm exec <node version> <command>'

Small print

Author: Gleb Bahmutov © 2016

License: MIT - do anything with the code, but don't blame me if it does not work.

Spread the word: tweet, star on github, etc.

Support: if you find any problems with this module, email / tweet / open issue on Github

项目地址: https://github.com/bahmutov/all-nvm