我想检查一下是否在系统上安装了nodejs.我收到此错误:
错误:找不到命令.
我该如何解决?
#!/bin/bash
if [ nodejs -v ]; then
echo "nodejs found"
else
echo "nodejs not found"
fi
Run Code Online (Sandbox Code Playgroud)
hek*_*mgl 13
你可以使用commandbash内置:
if command -v nodejs >/dev/null 2>&1 ; then
echo "nodejs found"
echo "version: $(nodejs -v)"
else
echo "nodejs not found"
fi
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5754 次 |
| 最近记录: |