简体   繁体   中英

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

I moved my typescript project to a win 7 computer. I get this error when the tsconfig works perfectly fine in my win 10 computer. I removed the last two trailing commas as suggested here and the error persists.

My 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
  }
}

It also surprises me that when I run

tsc --init

I obtain:

error TS5023: Unknown compiler option 'init'.

Thanks for any help.

I kept getting the same error messages because I had a tsc installed globally. I uninstalled it and installed the typescript package which solved the problem.

I had this problem and it happened because I downgraded my typescript. After that I removed tsconfig.json file then tsc worked. Probably There was some new config's that added in newer versions of Typescript. Therefore I start to figure out witch one is newly added:

    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'.

then It solved. There is a beautiful tip that i was using these configs for weeks on newer version of typescript and their working.

Check it and see what happens :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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