在OS X上使用nvm重新安装节点而不删除node_modules? [英] Reinstall node using nvm on OS X without removing node_modules?

查看:93
本文介绍了在OS X上使用nvm重新安装节点而不删除node_modules?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照最新建议,我决定删除以前可以正常工作的Homebrew节点安装并使用 nvm改为安装节点,并进行设置以避免使用sudo。

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

我仔细清理了以下文件夹(由我的用户拥有),除了两个模块用于长期使用旧版本节点的Ember项目(因为我没有有信心在以后重新安装所需的版本):

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

如果我保留现有的/ usr / local / lib / node_modules /文件夹使用bower和ember-cli的版本,这会在安装nvm以及节点版本时引起任何问题我需要吗?

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?

推荐答案

NVM使用单独的node_modules文件夹



对话在这里对我自己说,但是在让问题开放15个多小时之后,我才继续(并遵循GitHub上的nvm指南)安装了带有curl的nvm ,最新的长期支持(LTS)节点带有 nvm install --lts

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

以前,我使用 n来管理节点版本,但是NVM将node_modules存储在一个目录中,该目录由您当前正在使用的节点的版本确定,您可以在 npm root -g 中找到该目录,例如〜/ .nvm / versions / node / v10.15.3 / lib / node_modules

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

因此, n在 / usr / local / lib / node_modules / 中使用的先前的node_modules文件夹未被nvm使用,可以删除。在彻底清除并



























strong>重新安装存储在其中的以前的节点模块。

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.

这篇关于在OS X上使用nvm重新安装节点而不删除node_modules?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆