问题
Following the latest advice I decided to remove a previous working Homebrew node install and use nvm to install node instead, and also set things up to avoid using sudo.
However, before going further
I carefully cleaned out the following folder (owned by my user) except for two modules used for a long-standing Ember project that uses an older version of node (because I'm not confident of reinstalling the required version of them later):
/usr/local/lib/node_modules/
bower
ember-cli
If I keep the existing /usr/local/lib/node_modules/ folder with the versions of bower and ember-cli, will this cause any issue on installing nvm and then the node versions I need?
回答1:
NVM uses separate node_modules folder
Talking to myself here, but after leaving the question open for 15+ hours I just went ahead and (following the nvm guide on GitHub) installed nvm with curl, the latest Long Term Support (LTS) node with nvm install --lts
Previously, I was using n to manage node versions, but NVM stores node_modules in a directory determined by the version of node you're currently using, which you can find with npm root -g
e.g. ~/.nvm/versions/node/v10.15.3/lib/node_modules
So, the previous node_modules folder used by n at /usr/local/lib/node_modules/
is unused by nvm and can be deleted. After a thorough clean-out and brew uninstall
of all the previous node installation there were no issues with new nvm install, and I now have to reinstall the previous node modules stored there.
来源:https://stackoverflow.com/questions/55735701/reinstall-node-using-nvm-on-os-x-without-removing-node-modules