I have two projects:
- project A: Node 16.10.0 NPM 7.24.2
- project B: Node 16.10.0 NPM 8.10.0
Both require the same version of Node but different versions of NPM. I am wondering if it can be achieved with NVM.
I was able to do it (on MacOS) but it is rather hacky
nvm use v16.10.0
npm -v # 7.24.2
which node # /Users/useriko/.nvm/versions/node/v16.10.0/bin/node
# duplicate v16.10.0 folder
ditto ~/.nvm/versions/node/v16.10.0 ~/.nvm/versions/node/v16.10.0_npm8
nvm use v16.10.0_npm8
npm i -g npm@8.10.0
nvm alais v16_npm7 v16.10.0
nvm alias v16_npm8 v16.10.0_npm8
now I can toggle between them
nvm use v16_npm7for npm 7.24.2nvm use v16_npm8for npm 8.10.0
Is there a better/alternative solution?