Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nodemon not working properly

I am running my nodejs app by npm start

I just installed nodemon by sudo npm install -g nodemon so that i can get my server restarted when i save changes to files.

But when i try to start the server, something like this

nodemon ./app.js localhost 3000 or nodemon start localhost 3000

I get this as output

LM-SJC-00871929:webapp gdeep$ nodemon ./app.js localhost 3000 28 May 23:34:30 - [nodemon] v1.1.1 28 May 23:34:30 - [nodemon] to restart at any time, enter `rs` 28 May 23:34:30 - [nodemon] watching: *.* 28 May 23:34:30 - [nodemon] starting `node ./app.js localhost 3000` 

but when i go to my webpage, i get

Oops! Google Chrome could not connect to localhost:3000. What am i doing wrong?

App.js here http://collabedit.com/t35dy

like image 820
bruceparker Avatar asked May 29 '14 06:05

bruceparker


People also ask

How do I fix Nodemon is not working?

Use npx to solve the error "'nodemon' is not recognized as an internal or external command, operable program or batch file", e.g. npx nodemon server. js or install the package globally by running npm install -g nodemon and make sure your PATH environment variable is set up correctly.

How do you refresh Nodemon?

When Nodemon restarts the ExpressJS server on changes, Livereload recreates the server and sends to the browser a refresh command when connected liveReloadServer. refresh("/"); . app.


1 Answers

You're running express 4, which has the app.listen call in a different file than app.js. The command you're looking for is nodemon bin/www (localhost and 3000 are not needed in this scenario).

In fact, you can even run nodemon with no args, and it'll read what command needs to be run from scripts.start in package.json (which express generates automatically).

like image 87
SomeKittens Avatar answered Sep 28 '22 07:09

SomeKittens