我試圖將國際化添加到我的Angular 2項目中,並且遵循intructions in the docs。無法提取ng-xi18n ENOENT:沒有這樣的文件或目錄
我使用angular-cli
開始項目,我的tsconfig.json
位於/ src。
運行命令:
./node_modules/.bin/ng-xi18n -p src/tsconfig.json
我得到以下錯誤:
Error: ENOENT: no such file or directory, open '/home/project/dist/out-tsc/src/app/_models/example.metadata.json'
at Error (native)
at Object.fs.openSync (fs.js:641:18)
at Object.fs.writeFileSync (fs.js:1347:33)
at MetadataWriterHost.writeMetadata (/home/project/node_modules/@angular/tsc-wrapped/src/compiler_host.js:164:22)
at MetadataWriterHost.writeFile (/home/project/node_modules/@angular/tsc-wrapped/src/compiler_host.js:143:19)
at Object.writeFile (/home/project/node_modules/typescript/lib/typescript.js:64240:132)
at Object.writeFile (/home/project/node_modules/typescript/lib/typescript.js:9020:14)
at printSourceFileOrBundle (/home/project/node_modules/typescript/lib/typescript.js:61204:16)
at emitSourceFileOrBundle (/home/project/node_modules/typescript/lib/typescript.js:61155:21)
at Object.forEachEmittedFile (/home/project/node_modules/typescript/lib/typescript.js:8986:17)
Extraction failed
而且這不是錯,目錄/home/project/dist/out-tsc/src/app/
不存在,取而代之的則是/home/project/dist/out-tsc/app/
。但我不知道如何解決它。
我懷疑的OUTDIR參數tsconfig.json
{
"compilerOptions": {
"baseUrl": "",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es2016",
"dom"
],
"mapRoot": "./",
"module": "es2015",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
]
},
"exclude": [
"app/testing/*",
"app/**/*.spec.ts",
"test.ts"
]
}
如果是在所有相關@angular/compiler-cli
和@angular/platform-server
都在2.4.10版本,NPM是給我了以下問題:
[email protected] invalid
UNMET PEER DEPENDENCY @angular/[email protected]
UNMET PEER DEPENDENCY @angular/[email protected]
其中角CLI版本是你嗎? ng-xi18n是angular-cli的一部分。 –
angular-cli在3.10.10版 – Niel
沒有3.10.10 ...最新版本是1.0.0 –