Skip to content

Instantly share code, notes, and snippets.

@miguelrincon
Created March 22, 2017 08:41
Show Gist options
  • Save miguelrincon/4fae792cf530552660e364352317fe28 to your computer and use it in GitHub Desktop.
Save miguelrincon/4fae792cf530552660e364352317fe28 to your computer and use it in GitHub Desktop.
# Use `npm run --` to avoid global installs of modules
# We can use npm scripts to "proxy" to locally installed packages without global
# installations and without appending ./node_modules/... to the command we want
# to call.
# PROBLEM:
# Calling a locally installed module from the terminal won't work:
$ webpack
webpack: command not found
# Calling a locally installed module using ./node_modules is ugly
$ ./node_modules/webpack/bin/webpack.js --version
2.2.1
{
"devDependencies": {
"webpack": "*",
"karma": "*"
},
"scripts": {
"webpack": "webpack",
"karma": "karma"
}
}
# Use npm to call webpack with double dash: "npm run --"
$ npm run webpack -- --version
> [email protected] webpack /home/miguelrincon/myproject
> webpack "--version"
2.2.1
# Use any argument
$ npm run webpack -- stats
> [email protected] webpack /home/miguelrincon/myproject
> webpack "stats"
...
bundle.js 2.02 MB 0 [emitted] [big] main
[1] ../~/webpack/buildin/global.js 509 bytes {0} [built]
+ 26 hidden modules
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment