When using NVM, or otherwise switching between Node.js versions, node_modules has to be rebuilt for each Node version. Would it be possible somehow use a different node_modules directory for each version, instead of having to rebuild the contents everytime you switch between versions?
something like:
node_modules_v8/
node_modules_v7/
node_modules_v6/
Maybe there is a better way to do this, not sure.
Three suggestions (in my order of pref):
node_modulesfolder that points to the correct version of modules thatnodeexpects to run.NODE_PATHsetting and point it to the correct cache of yournode_modulesfolder (i.e. NODE_PATH=/etc/node_v8) just prior to executing yournodecommand. If you set it globally it would restrict you running multiple instances of node on that box so, you'd need to set theNODE_PATHon a per process instance.