nodemon无法正常工作 [英] nodemon not working properly

查看:629
本文介绍了nodemon无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过npm start

我刚刚通过安装了nodemon sudo npm install -g nodemon,以便在保存对文件的更改时可以重新启动服务器.

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

我得到这个作为输出

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.我在做什么错了?

App.js此处 http://collabedit.com/t35dy

推荐答案

您正在运行Express 4,它在与app.js不同的文件中调用了app.listen.您要查找的命令是nodemon bin/www(在这种情况下不需要localhost3000).

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).

实际上,您甚至可以不带参数地运行nodemon,它会从package.json中的scripts.start中读取需要运行的命令(表达式自动生成).

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).

这篇关于nodemon无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆