cheton / browserify-css

A Browserify transform for bundling, rebasing, inlining, and minifying CSS files.
http://cheton.github.io/browserify-css/
MIT License
144 stars 22 forks source link

Browserify fails to require browserify-css when the package is installed globally #48

Closed snajjar closed 7 years ago

snajjar commented 7 years ago

Hello, It seems that a simple browserify command like below will work fine if browserify-css is installed locally (in the current repository):

$ browserify input.js -g browserify-css -o output.js

But the exact same command will fail if the browserify-css package is installed globally (npm install -g):

$ browserify input.js -g browserify-css -o output.js
Error: Cannot find module 'browserify-css' from '/tmp'
  at /usr/lib/node_modules/browserify/node_modules/resolve/lib/async.js:46:17
  at process (/usr/lib/node_modules/browserify/node_modules/resolve/lib/async.js:173:43)
  at ondir (/usr/lib/node_modules/browserify/node_modules/resolve/lib/async.js:188:17)
  at load (/usr/lib/node_modules/browserify/node_modules/resolve/lib/async.js:69:43)
  at onex (/usr/lib/node_modules/browserify/node_modules/resolve/lib/async.js:92:31)
  at /usr/lib/node_modules/browserify/node_modules/resolve/lib/async.js:22:47
  at FSReqWrap.oncomplete (fs.js:123:15)

My NODE_PATH is set correctly, and if i run node, i can require('browserify-css') in it without a problem (on both install: local dir and global). I've been scratching my hair around this, can you please give me some lights?

Thank you :)

cheton commented 7 years ago

Browserify transforms should be installed locally, and I'd recommend you use local dependencies for browserify transforms. You can check out this issue at https://github.com/substack/node-browserify/issues/1206 to find a workaround.