错误 TS5014:无法解析文件“tsconfig.json”:位置 57 处的意外令牌/JSON

rus*_*Bay 1 typescript tsconfig

我将我的打字稿项目移到了 win 7 计算机上。当 tsconfig 在我的 win 10 计算机上运行良好时,我收到此错误。我按照此处的建议删除了最后两个尾随逗号,但错误仍然存​​在。

我的 tsconfig:

{
  "compileOnSave": true,
  "compilerOptions": {
    /* Visit https://aka.ms/tsconfig.json to read more about this file */
    /* Basic Options */
    // "incremental": true,                   /* Enable incremental compilation */
    "target": "es5",                          /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
    "module": "commonjs",                     /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
    "strict": true,                           /* Enable all strict type-checking options. */
    // "esModuleInterop": true,                  /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
    //"inlineSourceMap": true,                  /* Emit a single file with source maps instead of having a separate file. */
    //"inlineSources": true,                    /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
    "sourceMap": true,
    /* Advanced Options */
    "skipLibCheck": true,                     /* Skip type checking of declaration files. */
    "forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
    "outDir": "./src/ts-built",
    //"rootDir": "./src",
    // "strictNullChecks": false,
    "baseUrl": "src",
    "allowJs": true,
    "downlevelIteration": true
  }
}
Run Code Online (Sandbox Code Playgroud)

也让我惊讶的是,当我跑步时

tsc --init
Run Code Online (Sandbox Code Playgroud)

我获得:

错误 TS5023:未知的编译器选项“init”。

谢谢你的帮助。

小智 5

我一直收到相同的错误消息,因为我在全球安装了tsc。我卸载了它并安装了解决问题的打字稿包。