le0m le0m - 2 years ago 148
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download