le0m le0m - 1 year ago 80
Node.js Question

Install and use independent node.js enviroments in different project directories

I really like virtual environments in Python, where you can put a whole Python environment including the interpreter into a project directory. If you dig out an old project after years you can just activate the environment and you are ready to go - this is awesome.

What is the node.js way of doing this?


Usually you mark down the package versions and Node.js version that your code supports in the appropriate package.json directive. This means that distributed versions of your projects import the same modules. Locally, this doesn't matter as npm installs your packages in the project directory by default.

However, for managing your local Node versions more efficiently, a tool such as Node Version Manager will do the trick. NVM specifically supports a .nvmrc file in the project directory to mark down the Node version.