I have installed serve with npm as "npm install serve -g" and also with yarn "yarn global add serve", but when I try to run "serve -s build" it says that "Command 'serve' not found.
You should not install the packages globally.Try to do the following-
npm uninstall -g serve
npm i -S serve
Let me know if this works.
None of these above answers worked for me, so this is what works for me :
sudo su
npm install -g serve
Installing as root helps globally installing serve
Make sure to have this in your .bashrc
or .zshrc
if you're using Yarn:
export PATH="$PATH:$(yarn global bin)"
if you're using NPM:
export PATH="$(npm bin -g):$PATH"
So that the shell would know where to look for executables such as serve
, npx
, live-server
etc that are installed globally.
Make sure to reload your shell config:
source ~/.bashrc // or ~/.zshrc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With