【发布时间】:2020-08-21 18:28:41
【问题描述】:
我尝试使用当前的 stackoverflow 方法,但仍然得到bash: http-server: command not found
还有 npm list -g http-server 返回:
pi@raspberrypi:/usr/local/lib/node_modules $ npm list -g http-server
/usr/local/lib
└── (empty)
echo $PATH 根据 .bashrc 文件返回后续结果:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/usr/.npm-global/bin:/usr/.npm-global/bin:/usr/local/lib/node_modules
另外我用这个命令sudo npm install http-serve -g 安装它,它可以看到它的输出如下:
/root/.npm-global/bin/http-serve -> /root/.npm-global/lib/node_modules/http-serve/bin/http-serve
/root/.npm-global/bin/hs -> /root/.npm-global/lib/node_modules/http-serve/bin/http-serve
+ http-serve@1.0.1
added 21 packages from 25 contributors in 13.863s
【问题讨论】:
-
您正在安装
http-serve并调用http-server命令 -
抱歉打错了,
sudo npm install http-server -g和sudo npm install -g angular-http-server的结果相同 -
运行
find / -name "*http*server*" -print以查找文件所在的位置。然后将该目录添加到您的$PATH变量中,然后重试。如果文件不存在,那么它没有安装,或者没有使用您期望的文件名。如果您知道它在哪里,请尝试从完整路径开始。如果可行,请再次将目录添加到您的 $PATH 变量中。 -
感谢@Nic3500 它返回
/root/.npm-global/lib/node_modules/http-server /root/.npm-global/lib/node_modules/http-server/lib/http-server.js /root/.npm-global/lib/node_modules/http-server/bin/http-server /root/.npm-global/lib/node_modules/http-server/doc/http-server.1 /root/.npm-global/lib/node_modules/angular-http-server /root/.npm-global/lib/node_modules/angular-http-server/lib/angular-http-server.js /root/.npm-global/share/man/man1/http-server.1 /root/.npm-global/bin/http-server /root/.npm-global/bin/angular-http-server /usr/local/bin/http-server我的路径包括所有这些 -
确实...如果您指定完整路径(
/root/.npm-global/lib/node_modules/http-server?即您是否有权限?我知道至少有 1 种 unix 风格,如果权限不行,就算存在也会说文件不存在。