![](/img/trans.png)
[英]TypeScript error TS5014: Unexpected token u in JSON at position 0
[英]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.