gpt4 book ai didi

node.js - Node 'http-server' 只能从 powershell 以管理员身份工作

转载 作者:太空宇宙 更新时间:2023-11-04 01:03:14 24 4
gpt4 key购买 nike

使用 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 非常相似,但问题是不同的(我的安装从一开始就是全局的)并且那里的解决方案对我不起作用,除非以管理员身份运行。

最佳答案

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

关于node.js - Node 'http-server' 只能从 powershell 以管理员身份工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25324140/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com