Reinstall node using nvm on OS X without removing node_modules?

有些话、适合烂在心里 提交于 2019-12-08 12:54:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!