【问题标题】:node 'http-server' only works as administrator from powershell节点“http-server”仅作为 powershell 的管理员工作
【发布时间】:2014-08-15 09:27:52
【问题描述】:

使用 npm 安装了“http-server”模块后,我只能以管理员身份启动 powershell 才能运行它。

例如:

npm install -g http-server

似乎工作正常,但是:

http-server

抛出错误:

http-server : The term 'http-server' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

但是,如果我以管理员身份启动 powershell,“http-server”会按预期启动服务器。

如何安装 npm/node http-server 以在 powershell 未以管理员身份运行时可用?

重复警察:这与this question 非常相似,但问题不同(我的安装从一开始就是全局的),除非以管理员身份运行,否则那里的解决方案对我不起作用。

【问题讨论】:

  • http-server 使用端口 80 吗?使用端口 80 不需要管理员权限吗?
  • 默认使用 8080,是否有同样的限制?
  • $ENV:Path 以管理员身份运行与普通用户运行时是否不同?
  • arco44 可能在正确的路径上 - 这个错误仅仅意味着它无法将该字符串与命令或函数相关联...查看端口号太过分了。
  • @AndrewM 我相信不会。只有 1024 及以下端口需要管理员权限。

标签: node.js powershell npm


【解决方案1】:

确保您的 PATH 环境变量包含您的 http-server 的路径。您可以在用户的​​ powershell 配置文件中执行此操作。您可以找到有关 powershell 配置文件的基本介绍here.

【讨论】:

  • 我已将此添加到环境变量中,但仍然面临同样的问题。你能帮帮我吗
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-11-25
  • 2016-01-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多