ekalinin / nodeenv

Virtual environment for Node.js & integrator with virtualenv
http://ekalinin.github.io/nodeenv/
Other
1.71k stars 212 forks source link

Installing into python venv overwrites VIRTUAL_ENV environment variable #243

Open karypid opened 5 years ago

karypid commented 5 years ago

Hello,

When I install nodeenv on my Windows 10 machine with Python 3.7.4 I get the following:

> python -m venv .venv
...
> .venv\Scripts\Activate.ps1
(.venv) > pip install nodeenv
... (installs version 1.3.3)
(.venv) > nodeenv -p
 * Install prebuilt node (13.1.0) ..... done.
 * Overwriting c:\users\u\ws\.venv\Scripts\activate.bat with new content
 * Overwriting c:\users\u\ws\.venv\Scripts\deactivate.bat with new content
 * Overwriting c:\users\u\ws\.venv\Scripts\Activate.ps1 with new content
You do not have sufficient privilege to perform this operation.
You do not have sufficient privilege to perform this operation.
Error: Failed to create nodejs.exe link
 * Install npm.js (latest) ...
(.venv) >

Why does nodenv overwrite the activate scripts removing the VIRTUAL_ENV environment variable? I see it sets the NODE_PATH and NODE_VIRTUAL_ENV environment variables (updating the PATH to include them). I feel that this is wrong. Other scripts may use VIRTUAL_ENV to determine the context they are running in and this breaks them.

Should it not APPEND to the existing activate script (i.e. add NODE_VIRTUAL_ENV/NODE_PATH leaving the rest alone) rather than overwrite it?

P.S. I see some errors regarding insuffucient privileges to perform some operation. Is that normal? Maybe the resulting activate scripts are like that due to the failing part of the setup?

asottile commented 4 years ago

appears to just be an oversight -- https://github.com/ekalinin/nodeenv/blob/e0914ddcd4e051243eca48403f32607f5e910ed5/nodeenv.py#L900-L905

as for the permission errors, it's likely attempting to symlink (which is fine if it can't)

ravigupta-art commented 4 years ago

@karypid , I think what you need to do is after activating python venv and installing nodeenv, you need to create the nodeenv environment like this: $ nodeenv env where env is the name of the nodeenv environment and you can name it as per your wish. And, then activate it. You can find more information here: https://ekalinin.github.io/nodeenv/