为什么找不到nodejs?

时间:2016-04-05 02:05:31

标签: linux node.js ssh

我尝试通过SSH在我的服务器上安装某些软件,但由于某种原因无法找到node.js。我输入:

    './public_html/server/Start-linux.sh'

进入引用安装脚本文件的命令行,其代码为:

 #!/bin/bash

##Function Definition
pause() {
read -p "Press [Enter] key to exit"
}


cd $(dirname $0) # cd scr dir
if [ ! "$(id -u)" = 0 ] && [ ! -f ".readwarning" ]; then
    echo "WARNING: Ogar uses priveleged ports by default, which may" \
        "cause an error. Please either change the ports in the config" \
        "file (gameserver.ini) to two different ports above 1024, or run" \
        "this script as root. This warning will only be shown once, unless" \
        "the file \".readwarning\" is deleted" 1>&2
    touch .readwarning
    sleep 5
fi

#Check which command to execute, nodejs (debian based) or node (others)
#This will give priority to nodejs
command -v nodejs &>/dev/null
if [ $? -eq 0 ]; then
nodejs index.js
else
command -v nodejs &>/dev/null

if [ $? -eq 0 ]; then
    node index.js
else
     nodejs index.js echo "Couldn't find nodejs. Please install it and ensure       it is in your \$PATH"
fi
fi

# Pause
#pause

然后我收到一条错误消息:"无法找到nodejs。请安装它并确保它在$ PATH"。

当我键入' node -v'在命令行中它返回' v4.4.2',显然它就在那里。为什么会说它没有被发现?还有什么是$ PATH?我如何确保nodejs在$ path中?

我是SSH和node.js的初学者,所以任何帮助都将不胜感激。我在linux centos 64bit系统中。

2 个答案:

答案 0 :(得分:0)

nodejs是某些系统上Node.js二进制文件的名称,以避免与作为Ubuntu一部分的amateur packet radio networks的名为node node的旧程序发生冲突。他们真的应该重命名这个包,避免一切混乱。

首选名称为node,调用nodejs是特定于平台的。我认为您可以将这些调用重命名为node,而且它可以正常工作。

答案 1 :(得分:0)

您检查了nodejs两次:command -v nodejs &>/dev/null

您的第二次检查应为command -v node &>/dev/null

相关问题