Issue
I have a command that must be run with Node 16 installed, no other version. However, I need to have the latest version of Node installed for regular use.
How can I configure things, perhaps with environment variables, so that just that one command uses Node 16?
Something like nvm use 16 && node -v && nvm use 19
is too slow, but aliasing in .zshrc
is an option.
Solution
What I've done in one of my Projects is this:
I've switched to node 16: nvm use 16
.
After that which node
showed this path: /root/.nvm/versions/node/v16.19.0/bin/node
So I've simply created a symlink for this executable: ln -s $(which node) /usr/bin/node16
Finally I switched back the version: nvm use system
Now you can use your default node Version with node
and the desired node-version for this command with node16
.
Answered By - Nifess Answer Checked By - David Marino (WPSolving Volunteer)