Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save prasadtalasila/a5548c181a16846dc18466170897f925 to your computer and use it in GitHub Desktop.
Save prasadtalasila/a5548c181a16846dc18466170897f925 to your computer and use it in GitHub Desktop.
virtualenv like setup for node.js projects
Assume that a node project exists in /home/alan/autolabjs with the corresponding dependencies in
/home/alan/autolabjs/node_modules. Let's also say we have mocha dependency installed in node_modules.
Now, a regular way to use the installed dependencies is to execute mocha is as follows.
$cd /home/alan/autolabjs/
$./node_modules/.bin/mocha <rest of the command>
Since the soft links to all the installed node modules are available in
/home/alan/autolabjs/node_modules/.bin directory, we can add this directory to the PATH variable
to utilise all the installed dependencies like regular shell utilities.
$export PATH="/home/alan/autolabjs/node_modules/.bin":$PATH
Now to execute mocha, we only need to say
$mocha <rest of the command>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment