出错ERROR TS5055:无法写入文件'...',因为它会用allowJS和outDir选项覆盖输入文件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了出错ERROR TS5055:无法写入文件'...',因为它会用allowJS和outDir选项覆盖输入文件相关的知识,希望对你有一定的参考价值。
我收到以下错误:
我的tsconfig.json
文件
{
"compileOnSave": false,
"compilerOptions": {
"allowJs": true,
//"outFile": "./dist/out-tsc",
"outDir": "./dist",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
// "exclude": [
// "node_modules"
// ],
"lib": [
"es2017",
"dom"
]
}
}
我的tsconfig.app.json
文件:
"extends": "../tsconfig.json",
"compilerOptions": {
"allowJs": true,
//"noEmit": true,
//"outFile": "../out-tsc/app",
"outDir": "../out-tsc/app",
"baseUrl": "./",
"module": "es2015",
"types": []
},
"exclude": [
"node_modules",
"public",
"test.ts",
"**/*.spec.ts"
]
如果未注释的noEmit
项目成功运行,但它是空的。
Angular CLI: 1.6.0
Node: 8.9.1
OS: win32 x64
Angular: 5.1.0
angular/cli: 1.6.0
angular-devkit/build-optimizer: 0.0.35
angular-devkit/core: 0.0.22
angular-devkit/schematics: 0.0.41
ngtools/json-schema: 1.1.0
ngtools/webpack: 1.9.0
schematics/angular: 0.1.10
schematics/schematics: 0.0.10
typescript: 2.4.2
webpack: 3.10.0
答案
这个tsconfig对我有用:
{
"compileOnSave": false,
"compilerOptions": {
"allowJs": true,
"outDir": "./out-tsc",
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"traceResolution": true,
"target": "es5",
"baseUrl": "./src",
"paths": {
// APP
"app/*": ["./app/*"],
"components/*": ["./app/components/*"],
"services/*": ["./app/services/*"],
"global/*": ["./app/global/*"],
// ASSETS
"assets/*": ["./assets/*"],
// SHARED
"shared/*": ["./shared/*"],
"abstract/*": ["./shared/abstract/*"],
"interfaces/*": ["./shared/interfaces/*"]
},
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
和tsconfig.app:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"baseUrl": "./",
"module": "es2015",
"types": []
},
"exclude": [
//"../node_modules/**",
"public",
"test.ts",
"**/*.spec.ts"
]
}
以上是关于出错ERROR TS5055:无法写入文件'...',因为它会用allowJS和outDir选项覆盖输入文件的主要内容,如果未能解决你的问题,请参考以下文章
无法使用 TSC - 读取文件“anything.ts”时出错:找不到文件
logging error. UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1