1 Answer
- Newest
- Most votes
- Most comments
1
It sounds like activating the Python virtual environment is overriding the Node version set by NVM. A few things you could try:
- Add the NVM init script to the activate script of your Python virtualenv. This will ensure NVM is run everytime you activate the virtualenv:
echo "source ~/.nvm/nvm.sh" >> .venv/bin/activate
- Set the NODE_VERSION environment variable before activating the virtualenv. This will force a specific Node version when the virtualenv is activated:
export NODE_VERSION=v10.15.3
source .venv/bin/activate
-
Use a tool like n to switch Node versions instead of NVM. n can set Node version globally so it persists in new shells/environments.
-
Use a Docker container or similar to encapsulate the environment with both Node and Python configured how you need.
The core issue is that virtualenv overrides the shell environment, so you need to find a way to re-initialize NVM after activating virtualenv. Hopefully one of those suggestions helps! Let me know if you have any other questions.
answered a year ago
Relevant content
- asked 3 years ago
- asked a year ago
- asked 8 months ago
- asked 3 years ago
Thank you! All that sounds good. I ended up fixing things simply by running
nvm use default
in my shell immediately after doingsource .venv/bin/activate
.