[英]React serve -s build, The term 'serve' is not recognized as the name of a cmdlet
Hello I am trying to build my react app so I did yarn build
and it created the necessary folder now I am trying to do serve -s build
and it's telling me the error below您好,我正在尝试构建我的反应应用程序,所以我进行了
yarn build
,它创建了必要的文件夹,现在我正在尝试进行serve -s build
,它告诉我下面的错误
** I have tried to uninstall and reinstall serve by npm uninstall -g serve
and npm install -g serve
and I found the serve folder in C:\Users\Nairi\AppData\Roaming\npm\node_modules
** 我尝试通过
npm uninstall -g serve
和npm install -g serve
卸载并重新安装服务,我在C:\Users\Nairi\AppData\Roaming\npm\node_modules
Try npx serve -s build
I don't know why but they happened to me also and this worked尝试
npx serve -s build
我不知道为什么,但它们也发生在我身上,这很有效
Solution1 : yarn global add serve
解决方案1 :
yarn global add serve
As the Docs says, you can install it globally yarn global add serve
, then use it as you want like serve -s build
正如文档所说,您可以全局安装它
yarn global add serve
,然后根据需要使用它,例如serve -s build
Solution2: npx : npx serve -s build
解决方案2:npx :
npx serve -s build
As this article says, npx
will check whether <command>
or <package>
exists in $PATH
, or in the local project binaries( node_modules
), and if so it will execute it, and if it's not there, it will download it.正如本文所说,
npx
将检查$PATH
或本地项目二进制文件( node_modules
)中是否存在<command>
或<package>
,如果存在,它将执行它,如果不存在,它将下载它。 You can also run packages from github您还可以从 github 运行包
Check your admin permissions, so it can install globally with the -g flag检查您的管理员权限,以便可以使用 -g 标志全局安装
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.