已安装节点但在Ubuntu VPS中找不到节点 [英] Node installed but node cannot be found in Ubuntu VPS
问题描述
我通过NVM安装了节点。我安装了节点0.10.32。使用NVM 0.25.0
I installed node via NVM. I installed node 0.10.32. using NVM 0.25.0
当我做 node -v
我得到
-bash: /root/.nvm/v0.10.32/bin/node: No such file or directory
当我做 npm v
我得到
/root/.nvm/v0.10.32/bin/npm: 2: exec: /root/.nvm/v0.10.32/bin/node: not found
所有这些目录都存在且节点可执行文件在其中,但它们正在读取未找到的内容。节点似乎已安装但我无法使用它。我不知道如何解决这个问题。任何想法将不胜感激
All those directories exist and node executable is in it but they are reading as not found. Node seems to be installed but I am unable to use it. I am not sure how to fix this issue. Any ideas will be greatly appreciated
推荐答案
根据您的描述,很多事情都可能出错。通常我不建议使用nvm在服务器上安装Node。它适用于您在本地计算机上的工作,但是当您需要确定安装的内容和位置时,我建议您进行真正的安装。
A lot of things can be wrong here from what you describe. Generally I don't recommend using nvm to install Node on servers. It works fine for your own work on a local machine but when you need to be sure what is installed and where, I recommend doing a real installation.
我最近写了一个关于如何在Linux上安装Node的教程:
I recently wrote a tutorial on how to install Node on Linux:
- https://gist.github.com/rsp/edf756a05b10f25ee305cc98a161876a
具体是关于版本6.7.0但只是更改版本号以使用任何其他版本的Node。
It is specifically about version 6.7.0 but just change the version number to use any other version of Node.
您可以看到其他答案显示如何正确安装Node并进行故障排除安装不正确:
You can see other answers showing how to install Node properly and troubleshoot if it isn't installed correctly:
- Run npm as superuser, it isn't a good idea?
- node 5.5.0 already installed but node -v fetches with "v4.2.1" on OS X & homebrew?
只需获取所需版本的二进制或源代码包,将其安装到您想要的位置即可将工作。最可靠的方法是安装源包,因为你可以在安装之前运行 make test
,因为 npm
将有正确的shebang线(二进制分布可能并非总是如此 - 顺便提一下,nvm也使用它)。无需使用nvm或任何其他工具来执行此操作。
Just get the binary or source package of the version that you need, install it where you want and it will work. The most reliable way is to install a source package because you can run make test
before you install and because npm
will have the correct shebang line (which may not always be the case with binary distribution - which, incidentally, is also used by nvm). No need to use nvm or any other tool to do that.
如果您需要在本地计算机上进行开发期间快速切换Node版本,那么nvm非常棒但是如果您需要在服务器上安装Node的可靠方法,最好正常安装。
The nvm is great if you need to quickly switch Node versions during development on your local machine but if you want a reliable way to install Node on the server then it's best to install it normally.
这篇关于已安装节点但在Ubuntu VPS中找不到节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!