Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How npm start runs a server on port 8000

I recently used a angular-seed folder from github for angular application development. In some previous angularjs tutorial there was a script folder and a server.js file in the angular-seed folder which had all the configuration for running the node server. So how does npm now just start running a node server and where is all the configuration of that node server?

like image 854
user3724677 Avatar asked Jul 15 '14 05:07

user3724677


People also ask

What port does npm use?

The next time you run the npm start command, the default port used will be 7200 .


3 Answers

We have a react application and our development machines are both mac and pc. The start command doesn't work for PC so here is how we got around it:

"start": "PORT=3001 react-scripts start",
"start-pc": "set PORT=3001&& react-scripts start",

On my mac:

npm start

On my pc:

 npm run start-pc
like image 179
YeeHaw1234 Avatar answered Oct 24 '22 08:10

YeeHaw1234


To change the port

npm start --port 8000
like image 112
Kotireddy Avatar answered Oct 24 '22 08:10

Kotireddy


If you will look at package.json file.

you will see something like this

 "start": "http-server -a localhost -p 8000"

This tells start a http-server at address of localhost on port 8000

http-server is a node-module.

Update:- Including comment by @Usman, ideally it should be present in your package.json but if it's not present you can include it in scripts section.

like image 104
Mritunjay Avatar answered Oct 24 '22 09:10

Mritunjay