node.js - How to reconcile global webpack install and local loaders -
my package.json
includes webpack , loaders:
"devdependencies": { "babel-core": "^5.2.17", "babel-loader": "^5.0.0", "jsx-loader": "^0.13.2", "node-libs-browser": "^0.5.0", "webpack": "^1.9.4" }
when run webpack
it's not in path doesn't show found. installed globally npm install -g webpack
binary appear in path, can't find loader modules installed in ./node_modules
needs process dependency tree:
$ webpack --progress --colors --watch 10% 0/1 build modules/usr/local/lib/node_modules/webpack/node_modules/webpack-core/lib/normalmodulemixin.js:206 throw e; ^ error: cannot find module 'jstransform/simple'```
what preferred solution here?
i can install loaders globally, don't because of cross-project issues
i can try run webpack out of node_modules (not sure how honest, add $path
every project?)
or can try give global webpack access node_modules folder, seems hacky.
have done wrong, or there better community-approved way around maybe common problem?
i have blog post called managing per-project interpreters , path details methodology this. i'll summarize here address of key questions.
what preferred solution here?
never (really, literally never) use npm -g
. install within project. use shell set path appropriately. use zsh automatically detailed in blog post above if cd
project ./node_modules/.bin
, gets put on path automatically.
there other ways work including making aliases alias webpack="./node_modules/.bin/webpack"
, on. embrace changing path , you'll have harmonious long-term experience. needs of multiproject developer not met old school unix lives in either /bin or /usr/bin.
- if use npm scripts (the "scripts" key in
package.json
), npm automatically includes./node_modules/.bin
in path during scripts can run commands , found. make use of npm scripts , if make use of shell scripts that's easy placeexport path="$pwd/node_modules/.bin:$path"
.
Comments
Post a Comment