繁体   English   中英

为什么找不到nodejs?

[英]Why can't nodejs be found?

我试图通过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 64位系统中。

在某些系统上, nodejs是Node.js二进制文件的名称,以避免与旧版本程序(称为Ubuntu的业余分组无线网络的节点node冲突。 他们确实应该重命名该程序包,并避免所有混乱。

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

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

您的第二个检查应该是command -v node &>/dev/null

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM