gpt4 book ai didi

node.js - 默认 Node.js + Express.js 不运行

转载 作者:IT老高 更新时间:2023-10-28 23:00:38 32 4
gpt4 key购买 nike

我正在尝试学习使用 nodejsexpressjs 创建 Web 应用程序,遵循 the expressjs website 上的入门指南,在标题使用 express(1) 生成应用下。

我使用 express-generator 插件生成了一个应用,运行 npm install,然后尝试使用 node app 运行该应用(我还尝试了 node app.js 来衡量。运行这些命令中的任何一个时,终端都没有输出。

我也尝试过使用node debug app调试应用,结果如下:

< debugger listening on port 5858
connecting... ok
break in app.js:1
1 var express = require('express');
2 var http = require('http');
3 var path = require('path');
debug> cont
program terminated
debug> cont
App isn't running... Try `run` instead
debug>

我确实找到了一个文件 bin/www 似乎包含启动服务器的代码,果然,运行 node bin/www 成功启动了应用。

我在这里错过了什么?

最佳答案

看起来启动应用的方式已经改变。而不是 node app 你现在应该这样做

npm 开始

更多细节在这里https://github.com/expressjs/generator

关于node.js - 默认 Node.js + Express.js 不运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22215592/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com