In our environment, we're building a build/util tool to be used by many users without the need for external (or system-wide) dependencies. Namely, we're attempting to build this so that users won't have to be concerned with which version of node.js they have installed globally, as we're packing the node.js binary within the tool directory. (Please refrain from commenting on the merits of such an approach).
Our tool structure is as such:
/web/tool/
/web/tool/bin/ (where the node binary lives)
/web/tool/node_modules
We have /web/tool/bin added to the $PATH variable (first in order) upon execution of any of the scripts or grunt.js tasks to ensure that the local binaries path trumps any other.
Upon execution of any bash scripts or grunt.js tasks, the initial task locates the proper node binary. This was tested in an environment without node installed globally, so we knew it was finding the directory-local node binary. Any subsequent processes spawned from within these scripts/grunt-tasks however, are looking globally for the node binary.
Our specific user-case is running karma and phantomjs via a grunt task. The bash scripts/bins for karma, grunt-cli (grunt), and phantomjs all have the familiar header directive of
#!/usr/bin/env node
How should we go about setting up so that our tool is always looking for the directory-local node binary, even in subsequent child-processes?