I use Mac. I installed node, and then one day I use nvm. Everything is well when I am using IntelliJ IDEA. But when I use VS Code, I will see the following tips in terminal panel. And I need to execute command `nvm use v16.14.2` to toggle to the expected node version.
nvm is not compatible with the npm config “prefix” option: currently set to “/usr/local” Run
npm config delete prefix
ornvm use --delete-prefix v9.2.1
to unset it.
How to fix it?
1. Delete npm prefix
npm config delete prefix npm config set prefix $NVM_DIR/current
2. Delete node, node_modules, globally installed packages (not installed by nvm)
sudo rm -rf /usr/local/lib/node_modules sudo rm /usr/local/bin/node cd /usr/local/bin && ls -l | grep "../lib/node_modules/" | awk '{print $9}'| xargs rm
3. Set nvm
nvm alias default v16.14.2 nvm use v16.14.2
4. Validate
Close the current terminal panel and open a new one, then execute the follow command:
node -v
If the output is `v16.14.2`, then we succeed.