我在我的一个项目中使用 Angular 10,我无法在项目中使用本地化。
以下是我遵循的步骤:
- 首先,我使用添加了本地化包
ng add @angular/localize
- 然后我
i18n
在我的一个 HTML 标记中添加了该属性。 - 现在我正在尝试使用创建翻译文件
ng xi18n
但我收到以下错误:
Module build failed (from ./node_modules/@angular-devkit/build-angular/src/extract-i18n/ivy-extract-loader.js):
Error: Cannot find module '@angular/compiler-cli/src/ngtsc/sourcemaps'
Require stack:
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\localize\src\tools\src\extract\extraction.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\build-angular\src\extract-i18n\ivy-extract-loader.js
- F:\Work\aiFeed\publishers-portal\node_modules\loader-runner\lib\loadLoader.js
- F:\Work\aiFeed\publishers-portal\node_modules\loader-runner\lib\LoaderRunner.js
- F:\Work\aiFeed\publishers-portal\node_modules\webpack\lib\NormalModule.js
- F:\Work\aiFeed\publishers-portal\node_modules\webpack\lib\NormalModuleFactory.js
- F:\Work\aiFeed\publishers-portal\node_modules\webpack\lib\Compiler.js
- F:\Work\aiFeed\publishers-portal\node_modules\webpack\lib\webpack.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\build-webpack\src\webpack\index.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\build-webpack\src\index.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\build-angular\src\extract-i18n\index.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\index.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\models\architect-command.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\commands\xi18n-impl.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\schematics\tools\export-ref.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\schematics\tools\index.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\utilities\json-schema.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\models\command-runner.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\lib\cli\index.js
- C:\Users\Awais Ashraf\AppData\Roaming\npm\node_modules\@angular\cli\lib\init.js
- C:\Users\Awais Ashraf\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1080:15)
at Function.Module._load (internal/modules/cjs/loader.js:923:27)
at Module.require (internal/modules/cjs/loader.js:1140:19)
at require (internal/modules/cjs/helpers.js:75:18)
at F:\Work\aiFeed\publishers-portal\node_modules\@angular\localize\src\tools\src\extract\extraction.js:14:24
at F:\Work\aiFeed\publishers-portal\node_modules\@angular\localize\src\tools\src\extract\extraction.js:3:17
at Object.<anonymous> (F:\Work\aiFeed\publishers-portal\node_modules\@angular\localize\src\tools\src\extract\extraction.js:9:3)
at Module._compile (internal/modules/cjs/loader.js:1251:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
at Module.load (internal/modules/cjs/loader.js:1100:32)
at Function.Module._load (internal/modules/cjs/loader.js:962:14)
at Module.require (internal/modules/cjs/loader.js:1140:19)
at require (internal/modules/cjs/helpers.js:75:18)
at Object.<anonymous> (F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\build-angular\src\extract-i18n\ivy-extract-loader.js:10:22)
at Module._compile (internal/modules/cjs/loader.js:1251:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
Error: Module build failed (from ./node_modules/@angular-devkit/build-angular/src/extract-i18n/ivy-extract-loader.js):
Error: Cannot find module '@angular/compiler-cli/src/ngtsc/sourcemaps'
Require stack:
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\localize\src\tools\src\extract\extraction.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\build-angular\src\extract-i18n\ivy-extract-loader.js
- F:\Work\aiFeed\publishers-portal\node_modules\loader-runner\lib\loadLoader.js
- F:\Work\aiFeed\publishers-portal\node_modules\loader-runner\lib\LoaderRunner.js
- F:\Work\aiFeed\publishers-portal\node_modules\webpack\lib\NormalModule.js
- F:\Work\aiFeed\publishers-portal\node_modules\webpack\lib\NormalModuleFactory.js
- F:\Work\aiFeed\publishers-portal\node_modules\webpack\lib\Compiler.js
- F:\Work\aiFeed\publishers-portal\node_modules\webpack\lib\webpack.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\build-webpack\src\webpack\index.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\build-webpack\src\index.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\build-angular\src\extract-i18n\index.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\index.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\models\architect-command.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\commands\xi18n-impl.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\schematics\tools\export-ref.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\schematics\tools\index.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\utilities\json-schema.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\models\command-runner.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\lib\cli\index.js
- C:\Users\Awais Ashraf\AppData\Roaming\npm\node_modules\@angular\cli\lib\init.js
- C:\Users\Awais Ashraf\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1080:15)
at Function.Module._load (internal/modules/cjs/loader.js:923:27)
at Module.require (internal/modules/cjs/loader.js:1140:19)
at require (internal/modules/cjs/helpers.js:75:18)
at F:\Work\aiFeed\publishers-portal\node_modules\@angular\localize\src\tools\src\extract\extraction.js:14:24
at F:\Work\aiFeed\publishers-portal\node_modules\@angular\localize\src\tools\src\extract\extraction.js:3:17
at Object.<anonymous> (F:\Work\aiFeed\publishers-portal\node_modules\@angular\localize\src\tools\src\extract\extraction.js:9:3)
at Module._compile (internal/modules/cjs/loader.js:1251:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
at Module.load (internal/modules/cjs/loader.js:1100:32)
at Function.Module._load (internal/modules/cjs/loader.js:962:14)
at Module.require (internal/modules/cjs/loader.js:1140:19)
at require (internal/modules/cjs/helpers.js:75:18)
at Object.<anonymous> (F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\build-angular\src\extract-i18n\ivy-extract-loader.js:10:22)
at Module._compile (internal/modules/cjs/loader.js:1251:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
Error: ./src/main.ts
Module build failed (from ./node_modules/@angular-devkit/build-angular/src/extract-i18n/ivy-extract-loader.js):
Error: Cannot find module '@angular/compiler-cli/src/ngtsc/sourcemaps'
Require stack:
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\localize\src\tools\src\extract\extraction.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\build-angular\src\extract-i18n\ivy-extract-loader.js
- F:\Work\aiFeed\publishers-portal\node_modules\loader-runner\lib\loadLoader.js
- F:\Work\aiFeed\publishers-portal\node_modules\loader-runner\lib\LoaderRunner.js
- F:\Work\aiFeed\publishers-portal\node_modules\webpack\lib\NormalModule.js
- F:\Work\aiFeed\publishers-portal\node_modules\webpack\lib\NormalModuleFactory.js
- F:\Work\aiFeed\publishers-portal\node_modules\webpack\lib\Compiler.js
- F:\Work\aiFeed\publishers-portal\node_modules\webpack\lib\webpack.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\build-webpack\src\webpack\index.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\build-webpack\src\index.js
[91m- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\build-angular\src\extract-i18n\index.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\index.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\models\architect-command.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\commands\xi18n-impl.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\schematics\tools\export-ref.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\schematics\tools\index.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\utilities\json-schema.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\models\command-runner.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\lib\cli\index.js
- C:\Users\Awais Ashraf\AppData\Roaming\npm\node_modules\@angular\cli\lib\init.js
- C:\Users\Awais Ashraf\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1080:15)
at Function.Module._load (internal/modules/cjs/loader.js:923:27)
at Module.require (internal/modules/cjs/loader.js:1140:19)
at require (internal/modules/cjs/helpers.js:75:18)
at F:\Work\aiFeed\publishers-portal\node_modules\@angular\localize\src\tools\src\extract\extraction.js:14:24
at F:\Work\aiFeed\publishers-portal\node_modules\@angular\localize\src\tools\src\extract\extraction.js:3:17
at Object.<anonymous> (F:\Work\aiFeed\publishers-portal\node_modules\@angular\localize\src\tools\src\extract\extraction.js:9:3)
at Module._compile (internal/modules/cjs/loader.js:1251:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
at Module.load (internal/modules/cjs/loader.js:1100:32)
at Function.Module._load (internal/modules/cjs/loader.js:962:14)
at Module.require (internal/modules/cjs/loader.js:1140:19)
at require (internal/modules/cjs/helpers.js:75:18)
at Object.<anonymous> (F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\build-angular\src\extract-i18n\ivy-extract-loader.js:10:22)
at Module._compile (internal/modules/cjs/loader.js:1251:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
Error: ./src/polyfills.ts
Module build failed (from ./node_modules/@angular-devkit/build-angular/src/extract-i18n/ivy-extract-loader.js):
Error: Cannot find module '@angular/compiler-cli/src/ngtsc/sourcemaps'
Require stack:
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\localize\src\tools\src\extract\extraction.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\build-angular\src\extract-i18n\ivy-extract-loader.js
- F:\Work\aiFeed\publishers-portal\node_modules\loader-runner\lib\loadLoader.js
- F:\Work\aiFeed\publishers-portal\node_modules\loader-runner\lib\LoaderRunner.js
- F:\Work\aiFeed\publishers-portal\node_modules\webpack\lib\NormalModule.js
- F:\Work\aiFeed\publishers-portal\node_modules\webpack\lib\NormalModuleFactory.js
- F:\Work\aiFeed\publishers-portal\node_modules\webpack\lib\Compiler.js
- F:\Work\aiFeed\publishers-portal\node_modules\webpack\lib\webpack.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\build-webpack\src\webpack\index.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\build-webpack\src\index.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\build-angular\src\extract-i18n\index.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\index.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\models\architect-command.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\commands\xi18n-impl.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\schematics\tools\export-ref.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\schematics\tools\index.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\utilities\json-schema.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\models\command-runner.js
- F:\Work\aiFeed\publishers-portal\node_modules\@angular\cli\lib\cli\index.js
- C:\Users\Awais Ashraf\AppData\Roaming\npm\node_modules\@angular\cli\lib\init.js
- C:\Users\Awais Ashraf\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1080:15)
at Function.Module._load (internal/modules/cjs/loader.js:923:27)
at Module.require (internal/modules/cjs/loader.js:1140:19)
at require (internal/modules/cjs/helpers.js:75:18)
at F:\Work\aiFeed\publishers-portal\node_modules\@angular\localize\src\tools\src\extract\extraction.js:14:24
at F:\Work\aiFeed\publishers-portal\node_modules\@angular\localize\src\tools\src\extract\extraction.js:3:17
at Object.<anonymous> (F:\Work\aiFeed\publishers-portal\node_modules\@angular\localize\src\tools\src\extract\extraction.js:9:3)
at Module._compile (internal/modules/cjs/loader.js:1251:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
at Module.load (internal/modules/cjs/loader.js:1100:32)
at Function.Module._load (internal/modules/cjs/loader.js:962:14)
at Module.require (internal/modules/cjs/loader.js:1140:19)
at require (internal/modules/cjs/helpers.js:75:18)
at Object.<anonymous> (F:\Work\aiFeed\publishers-portal\node_modules\@angular-devkit\build-angular\src\extract-i18n\ivy-extract-loader.js:10:22)
at Module._compile (internal/modules/cjs/loader.js:1251:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
我一直在努力寻找解决方案很长一段时间,任何快速帮助将不胜感激。提前致谢。