36

I want to use NodeJS and AngularJS for a small project.

Can I use conda's virtualenv to install these packages inside a separate virtual environment, and then have them removed from the system once I delete the virtualenv?

4
  • You might want to look into Node version managers for that. nvs can be installed into a custom location (such as your virtualenv or project directory) Commented Jul 27, 2018 at 11:42
  • Thx, so, installing Node inside a conda virtualenv is the same as installing it on the system? It wont be removed if I delete the virtual env? Commented Jul 27, 2018 at 11:47
  • I haven't tried it TBH, but nvs gets installed in home directory by default. So deleting the virtualenv shouldn't affect it. Commented Jul 27, 2018 at 11:50
  • Okay, thx for the help Commented Jul 27, 2018 at 11:52

2 Answers 2

70

You can for sure use conda to create virtual environments for nodejs programs.

$ conda create -yn myapp nodejs $ conda activate myapp $ node --version v8.11.3 $ npm --version 5.6.0 

And then in the environment myapp, you can do all of your app development and once you are done, removal is also easy:

$ conda env remove -yn myapp 

Instead of environments, you can also use prefixes. Like:

$ conda create -yp ./myapp nodejs $ conda activate ./myapp $ node --version v8.11.3 $ npm --version 5.6.0 

And once you are done, just delete it.

$ conda env remove -yp ./myapp 

OR

$ rm -fr ./myapp 
Sign up to request clarification or add additional context in comments.

4 Comments

Spread the word! Conda is not tied to python, except the fact that it was written in python.
Then if I run npm install -g X in the conda env, will the global package X be in the conda env too? Are there related docs on "behavior of other package managers in conda env"?
npm install -g X will install X in /path/to/conda-environment-for-nodejs/lib/node_modules/X
@NehalJWani I can't get this to work. For some reason in my environment the system node is default and npm install -g X installs to system module path. stackoverflow.com/questions/69020379/…
1

You can even use environment.yml file to automatically manage your environments via conda. Please refer to this

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.