Node.js 正在本地服务器上启动节点js服务

Node.js 正在本地服务器上启动节点js服务,node.js,typescript,npm,Node.js,Typescript,Npm,我有一个node js gradle应用程序。我不知道如何在本地运行该应用程序 我已经完成了gradle构建(./gradlew)和npm运行构建(compile)。我的所有依赖项都在节点\u模块中 我有一个server.ts文件,除了路由之外还有服务器代码 mypackage.json- { "name": "app", "version": "..", "description": "", "main": "index.js", "types": "index.d.ts"

我有一个node js gradle应用程序。我不知道如何在本地运行该应用程序

我已经完成了gradle构建(./gradlew)和npm运行构建(compile)。我的所有依赖项都在
节点\u模块中

我有一个server.ts文件,除了路由之外还有服务器代码

mypackage.json-

{
  "name": "app",
  "version": "..",
  "description": "",
  "main": "index.js",
  "types": "index.d.ts",
  "scripts": {
    "prepublish": "npm run build",
    "build": "tsc",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "async-child-process": "^1.1.1",
    ..
  },
  "devDependencies": {
    "@types/handlebars": "^4.0.36",
    "@types/node": "^8.10.45",
    "@types/pg-types": "^1.11.4"
  }
}
如何在服务器上运行项目

tsconfig.json

{
    "compilerOptions": {
        "outDir": "./build/js/",
        "sourceMap": false,
        "noImplicitAny": false,
        "module": "commonjs",
        "declaration":true,
        "target": "es2015"
    },
    "include": [
        "src/main/ts/**/*.ts"
    ],
    "exclude": [
        "node_modules",
        "**/*.spec.ts"
    ]
}

Node.js不会运行ts代码。构建完成后,它将在dist目录中生成js代码(取决于tsconf.json)

在package.json中添加下面的代码,运行
npm run serve
启动服务器

或者转到dist dir并运行
node server.js

我已经在GitHub上创建了一个示例


@MarS在我的问题中更新了package.jsonadded tsconfig。没有dist文件夹present@themaster检查链接
"scripts": {
    "serve": "npm run build && npm run start",
    "start": "node dist/server.js",
    "build": "tsc"
}