ubuntu上使用n安装node,使用在命令行中不能用?

使用n成功安装成功了node

  ο node/18.17.1

Use up/down arrow keys to select a version, return key to install, d to delete, q to quit

但是输入命令

root@DESKTOP-GS0KUCE:~# node --version
-bash: /usr/bin/node: No such file or directory

应该怎么办

阅读 2.8k
2 个回答

1.删除已经存在的 /usr/bin/node 符号链接:

使用以下命令来删除 /usr/bin/node 符号链接:

sudo rm /usr/bin/node

2.创建新的符号链接:

使用以下命令来创建 /usr/bin/node 符号链接,确保它指向 n 安装的 Node.js 版本:

sudo ln -s /usr/local/bin/node /usr/bin/node

假设 /usr/local/bin/node 是 n 安装的 Node.js 的路径。如果你不确定 Node.js 的确切路径,可以使用以下命令来找到它:

which node

这将显示 Node.js 的路径。

3.验证 Node.js 安装:

最后,再次运行以下命令来验证 Node.js 版本:

node --version

确保它现在不再报告 "No such file or directory" 错误。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题