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

Viewed 5221

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

3 Answers

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

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

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

Related