MacOS 本地不同的NodeJS,如何找到并全部删除?

MacOS different NodeJS in local, how to find and remove them all?

我在 Mac 上切换 NodeJS 版本时遇到问题。我目前有 v12 NodeJS 并想降级到 v11,即使我尝试删除 /usr/local/lib/node_modules/usr/local/bin/usr/local/sharenode -v 中的节点文件和文件夹仍然有效精细打印 v12.18.3

这些是版本:

# Below command print: v12.18.3
node -v
# Try switching using `n` tool
n 11.15.0
# No errors printed out, then verify
node -v
# still prints v12.18.3

我把它添加到我的 NODE_PATH 但它也不起作用:

export NODE_PATH=/usr/local/bin

我试过重启shell终端,还是一样。

如何完全删除节点?只要能用,我不介意重装。

如果我运行npm config list:

; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.6 node/v12.18.3 darwin x64"

; userconfig /Users/jeemok/.npmrc
prefix = "/usr/local"

; builtin config undefined
prefix = "/usr/local"

; node bin location = /usr/local/Cellar/node@12/12.18.3/bin/node
; cwd = /Users/jeemok/tincode/admin-panel
; HOME = /Users/jeemok
; "npm config ls -l" to show all defaults.

是否与node bin location有关?如何将其更改为全局 NodeJS?我可以简单地删除 /usr/local/Cellar/node@12/ 文件夹吗?

注意:我已经试过了:

由于您已经在使用 homebrew,我建议使用它来安装 nodenv 以进行切换。

$ brew install nodenv
$ nodenv install 11.15.0

当您打开一个新的 shell 时,node 将是 select 节点版本的垫片。

nodenv local 将设置目录(项目)的版本。 shell 对于这个 session。 global 作为用户的默认值。

$ nodenv shell 11.15.0
$ node --version
v11.15.0

你还可以select需要的node默认系统版本:

$ nodenv versions
  system
  8.17.0
  10.22.0
  11.15.0
  12.18.3
  14.7.0