I prefer to store all generated files and dependencies outside my source tree while working on it.
npm and grunt make this hard: npm will never allow the local node_modules to be moved, so I have to use --global and --prefix . But grunt does not seem to support such a scheme.
How can I achieve my goal given the above limitations?
So, if I have a project:
foo/ .git/ src/ gruntfile.js package.json
I do not need additional files in my tree, in particular, node_modules . (Also bower_components and build , etc., but it's about npm.) This directory should remain intact while I work on it and run it. It's all.
Apparently, npm link should do this, but when I tried, it still installed all the dependencies in ./node_modules . Any other appeal that I cannot understand; the documents are not clear.
A related suggestion was to use another directory with a symbolic link for my gruntfile or package.json file, but grunt only allowed a symbolic link and continued to work in my source directory!
So far, the closest I have come to a link to, for example, ~/.cache/foo/node_modules from my project. Despite the fact that it ensures the preservation of prints from my tree, I still have this link cluttering up my workspace.
I want to know if there is a better way. Will some combination of npm install , npm link , ln , ~/.cache , NODE_PATH and PWD allow me to start my project from my source tree and keep it clean from all unhistorical artifacts?