繁体   English   中英

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

[英]error TS5014: Failed to parse file 'tsconfig.json': Unexpected token / in JSON at position 57

我将我的打字稿项目移到了 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
  }
}

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

tsc --init

我获得:

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

谢谢你的帮助。

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

我遇到了这个问题,这是因为我降级了我的打字稿。 之后我删除了tsconfig.json文件然后 tsc 工作。 可能在较新版本的 Typescript 中添加了一些新配置。 因此我开始想出新添加的女巫:

    error TS5023: Unknown compiler option 'strict'.
error TS6046: Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'esnext'
error TS5023: Unknown compiler option 'resolveJsonModule'.
error TS5023: Unknown compiler option 'checkJs'.
error TS5023: Unknown compiler option 'esModuleInterop'.
error TS5023: Unknown compiler option 'exclude'.
error TS5023: Unknown compiler option 'include'.

然后它解决了。 有一个很好的提示,我在较新版本的打字稿及其工作中使用这些配置数周。

检查它,看看会发生什么:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM