React serve -s build, The term 'serve' is not recognized as the name of a cmdlet
Asked Answered
S

4

9

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

Error

** 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

Sap answered 14/8, 2020 at 14:10 Comment(0)
C
23

Try npx serve -s build I don't know why but they happened to me also and this worked

Celio answered 14/8, 2020 at 14:35 Comment(0)
C
6

Solution1:

yarn global add serve

Based on NPM - Doc, you can install it globally yarn global add serve, then use it as you want like serve -s build

Solution2: 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. You can also run packages from github enter image description here

Claimant answered 11/5, 2021 at 11:16 Comment(0)
N
1

Check your admin permissions, so it can install globally with the -g flag

Nourish answered 19/8, 2020 at 13:53 Comment(0)
C
0

I don't know if anyone still needs this but you can use this yarn global add serve - Once this is successful, do yarn serve -s build. This worked for me!

Classieclassification answered 11/10, 2022 at 10:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.