rollup / rollup-watch

Fast incremental rebuilds with Rollup CLI
MIT License
91 stars 23 forks source link

globally installed (-g) rollup-watch not found by rollup #10

Closed talmobi closed 8 years ago

talmobi commented 8 years ago

Hey,

TL;DR -- rollup can't find globally installed rollup-watch (it finds locally installed ones though)

rollup (global) doesn't use the globally installed rollup-watch (says it doesn't exists and prints a recommendation to install it globally, even if it is). After I installed it locally it started to work.

Steps to reproduce:

mkdir -p ~/tmp
cd ~/tmp
mkdir rw_issue4
cd rw_issue4
npm install -g rollup
npm install -g rollup-watch
touch index.js
echo "{}" > package.json
echo "this will error (rollup-watch not found)
rollup -w -i index.js -o bundle.js
npm install --save-dev rollup-watch
echo "now the watch command will work as expected"
rollup -w -i index.js -o bundle.js
Rich-Harris commented 8 years ago

It sounds like you don't have a NODE_PATH variable set to wherever your modules are installed globally. You should be able to fix this by adding a line like the following to your ~/.bashrc (or ~/.zshrc or whatever) file:

export NODE_PATH=/path/to/your/node/lib/node_modules

...where you can find /path/to/your/node/ with npm get prefix. Alternatively, you can do it in the command itself like so:

export NODE_PATH=`npm get prefix`/lib/node_modules && rollup -c -w

Alternatively, there's no real harm in installing it locally – I just prefer installing this sort of thing locally since it's not used in CI builds etc.

talmobi commented 8 years ago

Yes you were absolutely right! Thank you for the great explanation and insight!

speg commented 8 years ago
ls $NODE_PATH
babel           electron-prebuilt   jshint          npm         rollup-watch        webpack
browserify      grunt-cli       madge           react-tools     stylus
brunch          jscs            node-libs-browser   rollup          typescript

rollup -cw
rollup --watch depends on the rollup-watch package, which could not be found. You can install it globally (recommended) with npm install -g rollup-watch

@Rich-Harris Any insight on this similar issue? I can only get it to work if I install rollup-watch locally as well.

eventualbuddha commented 8 years ago

I'm experiencing the same issue.

aubergene commented 8 years ago

I had this issue as NODE_PATH wasn't set. It isn't a problem I've encountered before so perhaps it would be good if rollup-watch could resolve the path itself?

ash0080 commented 8 years ago

@speg I have the same issue.

Mac-mini% echo $NODE_PATH
/usr/local/lib/node_modules
Mac-mini% rollup -cw
rollup --watch depends on the rollup-watch package, which could not be found. You can install it globally (recommended) with npm install -g rollup-watch
Type rollup --help for help, or visit https://github.com/rollup/rollup/wiki
Mac-mini%