【发布时间】:2023-01-21 06:01:52
【问题描述】:
尝试运行基于 Node、Nest 和 Typescript 构建的应用程序。我有以下 main.ts 文件。
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { VersioningType } from '@nestjs/common';
// Extending the string prototype
String.prototype.toSentence = function (sep) {
sep = sep || ' ';
return this.split(sep)
.map((v) => v.charAt(0).toUpperCase() + v.slice(1))
.join(sep);
};
function bootstrap() {
NestFactory.create(AppModule, { bodyParser: true, cors: true })
.then((app) => app.enableVersioning({ defaultVersion: '1', type: VersioningType.URI, prefix: 'v' }))
.then((app) => app.listen(3000, '0.0.0.0'));
}
bootstrap();
以下 package.json
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
},
并遵循 IntelliJ 配置,
我是 NodeJS 的新手,我正在尝试上面的事情但对我不起作用,这也导致我调试应用程序时出现问题。
但是,我可以使用“yarn start:dev”和其他选项启动应用程序,但根据 IntelliJ 文档,我正在按照此过程启动和调试应用程序。
这是链接> https://www.jetbrains.com/help/webstorm/running-and-debugging-node-js.html#ws_node_debug_from_run_tw
让我知道是否需要其他任何东西。
【问题讨论】:
-
从 Node.js 运行配置开始,您遇到过哪些问题?
-
编译失败
-
例如,您可以尝试来自github.com/nestjs/nest/issues/993#issuecomment-573584009 的食谱
-
我尝试了这些东西,它对我不起作用,因此再次发布。
标签: node.js typescript debugging intellij-idea