How do I use a local version of a module in node.js
. For example, in my app, I installed coffee-script:
npm install coffee-script
I encountered the same problem and I don't particularly like using aliases (as regular's suggested), and if you don't like them too then here's another workaround that I use, you first have to create a tiny executable bash script, say setenv.sh:
#!/bin/sh
# Add your local node_modules bin to the path
export PATH="$(npm bin):$PATH"
# execute the rest of the command
exec "$@"
and then you can then use any executables in your local /bin
using this command:
./setenv.sh
./setenv.sh 6to5-node server.js
./setenv.sh grunt
If you're using scripts
in package.json then:
...,
scripts: {
'start': './setenv.sh '
}