Monday, 12 June 2017

Can I use wildcards or semver ranges in version number when using `npm uninstall`?

I'm currently writing a quick upgrade script for a couple of projects we have that were previously using Gulp 3, and now using Gulp 4. The script should simply (globally) uninstall Gulp 3, then globally install Gulp 4 and gulp-cli. (We're on windows, and doing a global install of both is the only way we've gotten it to consistently work on our machines.)

The only caveat is that the exact version of Gulp 3 may be different from machine to machine, and we don't want the script to uninstall and reinstall Gulp 4 every time it gets run in the future. For that reason I'd like to specify the version of gulp to uninstall. If wildcards are supported in the version number, then I was going to just do npm rm -g gulp@3.*, but I'm guessing that wildcards are not, in fact, supported. In that case I'm hoping semver notation will work, in which case maybe something like npm rm -g gulp@<4.0.

Are either of those workable solutions? If not, what's the best way to basically do an "uninstall any gulp version starting with 3" via an npm script?(or batch file, I'm not picky)



via Isochronous

No comments:

Post a Comment