Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm command 'serve ' not found, although it is installed

Tags:

linux

npm

serve

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.

like image 994
Roland Avatar asked Apr 05 '19 07:04

Roland


Video Answer


3 Answers

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.

like image 135
techie_questie Avatar answered Oct 23 '22 15:10

techie_questie


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

like image 44
KKM Avatar answered Oct 23 '22 15:10

KKM


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
like image 25
Sumit Wadhwa Avatar answered Oct 23 '22 17:10

Sumit Wadhwa