I create a simple node project using express:
npm install -g express-generator express test cd test/ && npm install PORT=3000 npm start
So this gets the test app up and running on port 3000. Great. Now I'd like to use nodemon
to run this project. I've installed it:
npm install -g nodemon
In the gihub README it is run the same way as node. This is a bit confusing, because the new way of starting node is npm start
not node
. So I tried:
$ PORT=3000 nodemon ./app.js 13 May 23:41:16 - [nodemon] v1.0.18 13 May 23:41:16 - [nodemon] to restart at any time, enter `rs` 13 May 23:41:16 - [nodemon] watching: *.* 13 May 23:41:16 - [nodemon] starting `node ./app.js` 13 May 23:41:16 - [nodemon] clean exit - waiting for changes before restart
But when I try to connect, there's nothing there. I confirmed that with:
lsof -i TCP:3000
Which returned nothing. Normally (with npm start
) it returns:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME node 18746 user 10u IPv4 433546 0t0 TCP *:3000 (LISTEN)
Can anyone tell whats wrong here? How is it possible to get the app to listen on the specified port with nodemon
?
my setup:
npm -v 1.3.21 node -v v0.10.24 nodemon -v v1.0.18 express -V 4.2.0
js/Express. js App Only Works on Port 3000 - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.
The default port for HTTP is 80 – Generally, most web browsers listen to the default port. Below is the code implementation for creating a server in node and making it listen to port 80.
PORT || 3000 means: process. env. PORT means the PORT number you manually set. 3000 is the default port . If you havent set it manually then it will listen to 3000.
in package.json
"scripts":{ // "start": "node ./bin/www" "start": "nodemon ./bin/www" }
the following would now be equivalent:
$ npm start $ nodemon ./bin/www
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