Linux 为什么可以';找不到nodej?
我正试图通过SSH在服务器上安装一些软件,但由于某些原因,找不到node.js。I类型:Linux 为什么可以';找不到nodej?,linux,node.js,ssh,Linux,Node.js,Ssh,我正试图通过SSH在服务器上安装一些软件,但由于某些原因,找不到node.js。I类型: './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 ] &
'./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二进制文件的名称,以避免与旧程序NodeNode
冲突,因为后者是Ubuntu的一部分。他们真的应该重新命名这个包,避免所有的混乱
首选名称是
node
,调用nodejs
是特定于平台的。我认为您可以将这些调用重命名为node
,这样就可以了。您检查了nodejs
两次:命令-v nodejs&>/dev/null
您的第二个检查应该是
command-v node&>/dev/null
,或者您可以创建一个符号链接,使node
指向nodejs
,这就是在Debian/Ubuntu中通过apt
安装nodejs legacy
包所能做的。@msdex这是真的,但在本例中,我们讨论的是相反的情况,nodejs
不存在。