Angular 由于本地化,应用未 运行
Angular App not running because of localization
我有一个应用程序几天前还在运行。该应用程序使用本地化。一切看起来都很完美。突然它停止工作并开始给我这个错误。
Uncaught Error: It looks like your application or one of its dependencies is using i18n.
Angular 9 introduced a global `$localize()` function that needs to be loaded.
Please run `ng add @angular/localize` from the Angular CLI.
(For non-CLI projects, add `import '@angular/localize/init';` to your `polyfills.ts` file.
For server-side rendering applications add the import to your `main.server.ts` file.)
at push../node_modules/@angular/core/fesm5/core.js._global.$localize (core.js:32666:1)
at Module../node_modules/@ng-bootstrap/ng-bootstrap/fesm5/ng-bootstrap.js (ng-bootstrap.js:70:1)
at __webpack_require__ (bootstrap:84:1)
at Module../src/app/app.module.ts (app.component.ts:9:26)
at __webpack_require__ (bootstrap:84:1)
at Module../src/main.ts (main.ts:1:1)
at __webpack_require__ (bootstrap:84:1)
at Object.0 (main.ts:15:35)
at __webpack_require__ (bootstrap:84:1)
at checkDeferredModules (bootstrap:45:1)
我不确定我是否升级了 angular cli。但是一旦我开始收到这个错误,我就卸载了 angular cli 并安装了最新版本。但是没用。
已尝试执行 ng add @angular/localize
Installing packages for tooling via npm.
An unhandled exception occurred: npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @ng-bootstrap/ng-bootstrap@7.0.0
npm ERR! Found: @angular/common@9.1.11
npm ERR! node_modules/@angular/common
npm ERR! peer @angular/common@"9.1.11" from @angular/forms@9.1.11
npm ERR! node_modules/@angular/forms
npm ERR! @angular/forms@"^9.1.1" from the root project
npm ERR! peer @angular/common@"9.1.11" from @angular/platform-browser@9.1.11
npm ERR! node_modules/@angular/platform-browser
npm ERR! peer @angular/platform-browser@"9.1.11" from @angular/forms@9.1.11
npm ERR! node_modules/@angular/forms
npm ERR! @angular/forms@"^9.1.1" from the root project
npm ERR! peer @angular/platform-browser@"9.1.11" from @angular/platform-browser-dynamic@9.1.11
npm ERR! node_modules/@angular/platform-browser-dynamic
npm ERR! peer @angular/platform-browser-dynamic@"^9.0.6" from angular-datatables@9.0.2
npm ERR! node_modules/angular-datatables
npm ERR! angular-datatables@"^9.0.2" from the root project
npm ERR! 1 more (the root project)
npm ERR! 3 more (@angular/router, angular-datatables, the root project)
npm ERR! 9 more (@angular/platform-browser-dynamic, @angular/router, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^10.0.0" from @ng-bootstrap/ng-bootstrap@7.0.0
npm ERR! node_modules/@ng-bootstrap/ng-bootstrap
npm ERR! @ng-bootstrap/ng-bootstrap@"^7.0.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/common@10.2.5
npm ERR! node_modules/@angular/common
npm ERR! peer @angular/common@"^10.0.0" from @ng-bootstrap/ng-bootstrap@7.0.0
npm ERR! node_modules/@ng-bootstrap/ng-bootstrap
npm ERR! @ng-bootstrap/ng-bootstrap@"^7.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Shah Jahan\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Shah Jahan\AppData\Local\npm-cache\_logs22-04-30T07_47_17_303Z-debug-0.log
Package install failed, see above.
See "C:\Users\SHAHJA~1\AppData\Local\Temp\ng-fYNTDv\angular-errors.log" for further details.
生成的日志文件如下:
[error] Error: npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @ng-bootstrap/ng-bootstrap@7.0.0
npm ERR! Found: @angular/common@9.1.11
npm ERR! node_modules/@angular/common
npm ERR! peer @angular/common@"9.1.11" from @angular/forms@9.1.11
npm ERR! node_modules/@angular/forms
npm ERR! @angular/forms@"^9.1.1" from the root project
npm ERR! peer @angular/common@"9.1.11" from @angular/platform-browser@9.1.11
npm ERR! node_modules/@angular/platform-browser
npm ERR! peer @angular/platform-browser@"9.1.11" from @angular/forms@9.1.11
npm ERR! node_modules/@angular/forms
npm ERR! @angular/forms@"^9.1.1" from the root project
npm ERR! peer @angular/platform-browser@"9.1.11" from @angular/platform-browser-dynamic@9.1.11
npm ERR! node_modules/@angular/platform-browser-dynamic
npm ERR! peer @angular/platform-browser-dynamic@"^9.0.6" from angular-datatables@9.0.2
npm ERR! node_modules/angular-datatables
npm ERR! angular-datatables@"^9.0.2" from the root project
npm ERR! 1 more (the root project)
npm ERR! 3 more (@angular/router, angular-datatables, the root project)
npm ERR! 9 more (@angular/platform-browser-dynamic, @angular/router, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^10.0.0" from @ng-bootstrap/ng-bootstrap@7.0.0
npm ERR! node_modules/@ng-bootstrap/ng-bootstrap
npm ERR! @ng-bootstrap/ng-bootstrap@"^7.0.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/common@10.2.5
npm ERR! node_modules/@angular/common
npm ERR! peer @angular/common@"^10.0.0" from @ng-bootstrap/ng-bootstrap@7.0.0
npm ERR! node_modules/@ng-bootstrap/ng-bootstrap
npm ERR! @ng-bootstrap/ng-bootstrap@"^7.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Shah Jahan\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Shah Jahan\AppData\Local\npm-cache\_logs22-04-30T07_47_17_303Z-debug-0.log
Package install failed, see above.
at Object.installPackage (C:\Devs\Projects\LibMan\LibManWeb\node_modules\@angular\cli\tasks\install-package.js:39:15)
at AddCommand.run (C:\Devs\Projects\LibMan\LibManWeb\node_modules\@angular\cli\commands\add-impl.js:148:31)
at async AddCommand.validateAndRun (C:\Devs\Projects\LibMan\LibManWeb\node_modules\@angular\cli\models\command.js:134:28)
at async Object.runCommand (C:\Devs\Projects\LibMan\LibManWeb\node_modules\@angular\cli\models\command-runner.js:201:24)
at async default_1 (C:\Devs\Projects\LibMan\LibManWeb\node_modules\@angular\cli\lib\cli\index.js:62:31)
有人能帮忙吗?
我怀疑它正在尝试安装错误版本的 @angular/localize
。它应该正在安装 9.1.11
。更新您的 package.json
以包含该版本,然后 运行 npm install
。您可能需要先删除 node_modules
文件夹,因为它可能已经安装了不正确的文件依赖项。
请注意,所有 @angular/xxx
软件包都进行了版本控制,因此第一个数字与您 运行 正在使用的 angular 版本相匹配。即 @angular/localize : 9.1.11
我们知道它是 Angular 9.
我有一个应用程序几天前还在运行。该应用程序使用本地化。一切看起来都很完美。突然它停止工作并开始给我这个错误。
Uncaught Error: It looks like your application or one of its dependencies is using i18n.
Angular 9 introduced a global `$localize()` function that needs to be loaded.
Please run `ng add @angular/localize` from the Angular CLI.
(For non-CLI projects, add `import '@angular/localize/init';` to your `polyfills.ts` file.
For server-side rendering applications add the import to your `main.server.ts` file.)
at push../node_modules/@angular/core/fesm5/core.js._global.$localize (core.js:32666:1)
at Module../node_modules/@ng-bootstrap/ng-bootstrap/fesm5/ng-bootstrap.js (ng-bootstrap.js:70:1)
at __webpack_require__ (bootstrap:84:1)
at Module../src/app/app.module.ts (app.component.ts:9:26)
at __webpack_require__ (bootstrap:84:1)
at Module../src/main.ts (main.ts:1:1)
at __webpack_require__ (bootstrap:84:1)
at Object.0 (main.ts:15:35)
at __webpack_require__ (bootstrap:84:1)
at checkDeferredModules (bootstrap:45:1)
我不确定我是否升级了 angular cli。但是一旦我开始收到这个错误,我就卸载了 angular cli 并安装了最新版本。但是没用。
已尝试执行 ng add @angular/localize
Installing packages for tooling via npm.
An unhandled exception occurred: npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @ng-bootstrap/ng-bootstrap@7.0.0
npm ERR! Found: @angular/common@9.1.11
npm ERR! node_modules/@angular/common
npm ERR! peer @angular/common@"9.1.11" from @angular/forms@9.1.11
npm ERR! node_modules/@angular/forms
npm ERR! @angular/forms@"^9.1.1" from the root project
npm ERR! peer @angular/common@"9.1.11" from @angular/platform-browser@9.1.11
npm ERR! node_modules/@angular/platform-browser
npm ERR! peer @angular/platform-browser@"9.1.11" from @angular/forms@9.1.11
npm ERR! node_modules/@angular/forms
npm ERR! @angular/forms@"^9.1.1" from the root project
npm ERR! peer @angular/platform-browser@"9.1.11" from @angular/platform-browser-dynamic@9.1.11
npm ERR! node_modules/@angular/platform-browser-dynamic
npm ERR! peer @angular/platform-browser-dynamic@"^9.0.6" from angular-datatables@9.0.2
npm ERR! node_modules/angular-datatables
npm ERR! angular-datatables@"^9.0.2" from the root project
npm ERR! 1 more (the root project)
npm ERR! 3 more (@angular/router, angular-datatables, the root project)
npm ERR! 9 more (@angular/platform-browser-dynamic, @angular/router, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^10.0.0" from @ng-bootstrap/ng-bootstrap@7.0.0
npm ERR! node_modules/@ng-bootstrap/ng-bootstrap
npm ERR! @ng-bootstrap/ng-bootstrap@"^7.0.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/common@10.2.5
npm ERR! node_modules/@angular/common
npm ERR! peer @angular/common@"^10.0.0" from @ng-bootstrap/ng-bootstrap@7.0.0
npm ERR! node_modules/@ng-bootstrap/ng-bootstrap
npm ERR! @ng-bootstrap/ng-bootstrap@"^7.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Shah Jahan\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Shah Jahan\AppData\Local\npm-cache\_logs22-04-30T07_47_17_303Z-debug-0.log
Package install failed, see above.
See "C:\Users\SHAHJA~1\AppData\Local\Temp\ng-fYNTDv\angular-errors.log" for further details.
生成的日志文件如下:
[error] Error: npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @ng-bootstrap/ng-bootstrap@7.0.0
npm ERR! Found: @angular/common@9.1.11
npm ERR! node_modules/@angular/common
npm ERR! peer @angular/common@"9.1.11" from @angular/forms@9.1.11
npm ERR! node_modules/@angular/forms
npm ERR! @angular/forms@"^9.1.1" from the root project
npm ERR! peer @angular/common@"9.1.11" from @angular/platform-browser@9.1.11
npm ERR! node_modules/@angular/platform-browser
npm ERR! peer @angular/platform-browser@"9.1.11" from @angular/forms@9.1.11
npm ERR! node_modules/@angular/forms
npm ERR! @angular/forms@"^9.1.1" from the root project
npm ERR! peer @angular/platform-browser@"9.1.11" from @angular/platform-browser-dynamic@9.1.11
npm ERR! node_modules/@angular/platform-browser-dynamic
npm ERR! peer @angular/platform-browser-dynamic@"^9.0.6" from angular-datatables@9.0.2
npm ERR! node_modules/angular-datatables
npm ERR! angular-datatables@"^9.0.2" from the root project
npm ERR! 1 more (the root project)
npm ERR! 3 more (@angular/router, angular-datatables, the root project)
npm ERR! 9 more (@angular/platform-browser-dynamic, @angular/router, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^10.0.0" from @ng-bootstrap/ng-bootstrap@7.0.0
npm ERR! node_modules/@ng-bootstrap/ng-bootstrap
npm ERR! @ng-bootstrap/ng-bootstrap@"^7.0.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/common@10.2.5
npm ERR! node_modules/@angular/common
npm ERR! peer @angular/common@"^10.0.0" from @ng-bootstrap/ng-bootstrap@7.0.0
npm ERR! node_modules/@ng-bootstrap/ng-bootstrap
npm ERR! @ng-bootstrap/ng-bootstrap@"^7.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Shah Jahan\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Shah Jahan\AppData\Local\npm-cache\_logs22-04-30T07_47_17_303Z-debug-0.log
Package install failed, see above.
at Object.installPackage (C:\Devs\Projects\LibMan\LibManWeb\node_modules\@angular\cli\tasks\install-package.js:39:15)
at AddCommand.run (C:\Devs\Projects\LibMan\LibManWeb\node_modules\@angular\cli\commands\add-impl.js:148:31)
at async AddCommand.validateAndRun (C:\Devs\Projects\LibMan\LibManWeb\node_modules\@angular\cli\models\command.js:134:28)
at async Object.runCommand (C:\Devs\Projects\LibMan\LibManWeb\node_modules\@angular\cli\models\command-runner.js:201:24)
at async default_1 (C:\Devs\Projects\LibMan\LibManWeb\node_modules\@angular\cli\lib\cli\index.js:62:31)
有人能帮忙吗?
我怀疑它正在尝试安装错误版本的 @angular/localize
。它应该正在安装 9.1.11
。更新您的 package.json
以包含该版本,然后 运行 npm install
。您可能需要先删除 node_modules
文件夹,因为它可能已经安装了不正确的文件依赖项。
请注意,所有 @angular/xxx
软件包都进行了版本控制,因此第一个数字与您 运行 正在使用的 angular 版本相匹配。即 @angular/localize : 9.1.11
我们知道它是 Angular 9.