Ts node 仅包含ts节点的npm脚本失败

Ts node 仅包含ts节点的npm脚本失败,ts-node,npm-run,Ts Node,Npm Run,我有一个看似简单的npm脚本失败了,但我似乎不知道为什么。 我在全球安装了以下软件包: +-- ts-node@8.3.0 +-- tsconfig-paths@3.8.0 +-- typeorm-model-generator@0.3.4 `-- typescript@3.5.2 当我从命令行运行ts节点时,它会按预期运行 在我的package.json文件中,我有: "scripts": { "ts_test": "ts-node" }, 当我运行npm run ts_test时

我有一个看似简单的npm脚本失败了,但我似乎不知道为什么。 我在全球安装了以下软件包:

+-- ts-node@8.3.0
+-- tsconfig-paths@3.8.0
+-- typeorm-model-generator@0.3.4
`-- typescript@3.5.2
当我从命令行运行
ts节点时,它会按预期运行

在我的
package.json
文件中,我有:

"scripts": {
    "ts_test": "ts-node"
},
当我运行
npm run ts_test
时,我得到以下错误:

SyntaxError: Unexpected token } in JSON at position 581
    at JSON.parse (<anonymous>)
    at parse (...\node_modules\tsconfig\src\tsconfig.ts:195:15)
    at readFileSync (...\node_modules\tsconfig\src\tsconfig.ts:181:10)
    at Object.loadSync (...\node_modules\tsconfig\src\tsconfig.ts:151:18)
    at readConfig (...\node_modules\ts-node\src\index.ts:425:18)
    at Object.register (...\node_modules\ts-node\src\index.ts:189:18)
    at Object.<anonymous> (...\node_modules\ts-node\src\_bin.ts:140:17)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)

JSON规范不支持尾随逗号。因此,
tsconfig.json
的解析失败。将您的
tsconfig.json
更改为

{
  "compilerOptions": {
    "lib": [
      "es2017"
    ],    
    "baseUrl": "/",
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "strictNullChecks": true,
    "strictPropertyInitialization": false,
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es2017",
    "outDir": "lib",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "esModuleInterop": true
  },
  "exclude": [
    "node_modules"
  ]
}

请发布您的完整配置。好吧……这让WTF很尴尬。我花了6个小时寻找那个问题。谢谢
{
  "compilerOptions": {
    "lib": [
      "es2017"
    ],    
    "baseUrl": "/",
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "strictNullChecks": true,
    "strictPropertyInitialization": false,
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es2017",
    "outDir": "lib",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "esModuleInterop": true
  },
  "exclude": [
    "node_modules"
  ]
}