无法编译打字稿项目

时间:2020-04-26 06:49:19

标签: node.js typescript

运行打字稿文件时出现错误。运行npm start脚本后,我得到了错误提示。

neo4j_system_transaction_last_closed_tx_id_total{job='$job', instance=~"$neo4j_instance"}

tsconfig.json

    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
src/config/index.ts:4:23 - error TS2307: Cannot find module 'path'.

4 import * as path from "path";
                        ~~~~~~
src/config/index.ts:17:37 - error TS2304: Cannot find name '__dirname'.

17             .file({ file: path.join(__dirname, "/appConfig.json") });
                                       ~~~~~~~~~
src/config/index.ts:44:45 - error TS2304: Cannot find name '__dirname'.

44             this.sequelizeClient.addModels([__dirname + "../entities/*.js", __dirname + "../entities/*.ts"]);

package.json

{
  "compilerOptions": {
    "target": "es2015",
    "lib": ["es2015"],
    "types": ["reflect-metadata"],
    "module": "commonjs",
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "declaration": false
  },
  "exclude": ["node_modules"]
}

我已经安装了@ types / node,将类型更改为node会引发另一个错误。我在另一个项目中使用了相同的配置,效果很好。

0 个答案:

没有答案