在NPM中安装后找不到Http-Server命令 [英] Http-Server Command Not Found After Install in NPM

查看:594
本文介绍了在NPM中安装后找不到Http-Server命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在全球范围内用npm安装了http-server,但是仍然出现找不到命令"

i installed http-server with npm globally but still I get "command not found"

怎么了

我的npm命令是

npm install -g http-server

和http运行命令

http-server -p 8000

对于我来说,

推荐答案

关于PATH的问题.因为sh在指定的PATHS中找不到脚本.

as for me, this problem about the PATH. because the sh can't find the script in specifed PATHS.

您应该将npm全局脚本路径添加到PATH变量中.

you should add the npm global script path to your PATH variable.

如果您使用的是"Git Bash",请运行以下命令.

if you are using "Git Bash", run the below command.

PATH=$PATH:/c/Users/CHANGE_WITH_YOUR_USERNAME/AppData/Roaming/npm

请注意,这是暂时的.当您关闭git bash时,PATH变量将被删除.

notice that, this is temporary. when you close the git bash, the PATH variable will be deleted.

要永久保存,您必须在主文件夹中创建一个.bashrc文件.

for the permanently, you have to create a .bashrc file in your home folder.

在git bash上运行这些命令.

run these commands on your git bash.

cd ~
echo PATH=\$PATH:/c/Users/CHANGE_WITH_YOUR_USERNAME/AppData/Roaming/npm >> .bashrc

这篇关于在NPM中安装后找不到Http-Server命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆