【问题标题】:Running nodejs + Nest + typescript application using Node使用 Node 运行 nodejs + Nest + typescript 应用程序
【发布时间】: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 typescript debugging intellij-idea


【解决方案1】:

IDK 你得到了什么编译错误但是你在那里的运行配置对我不起作用。尝试将 Javascript 文件更改为 dist/main.js。这对我有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-10-27
    • 1970-01-01
    • 1970-01-01
    • 2022-11-12
    • 2019-06-07
    • 2021-07-17
    • 2017-10-15
    • 1970-01-01
    相关资源
    最近更新 更多