无法通过终端启动nodeapp

Unable to start the nodeapp through terminal

我在本地有一个节点应用程序,我通常 运行 它使用网络风暴中的 运行 按钮,效果很好。当我记录这个项目时,我遇到了这个拦截器:如果我尝试 运行 使用命令通过终端使用相同的应用程序: node app.js ,服务器启动但浏览器抛出错误并指出 "This site can’t be reached" "localhost refused to connect".

因为端口被占用

您可以使用 app.listen({port})...

更改它

linux: export PORT=4500 node server.js

windows: set PORT=4500 node server.js

我自己发现的..因为我使用了脚手架应用程序并且它在 bin/www 存储了与服务器相关的信息,所以我们将无法 运行 使用以下命令的应用程序:node app.js 但我们可以 运行 使用 nodemon 的应用程序(我在我的机器上全局安装)

喜欢 nodemon 的这个很棒的功能 <3 :)