将Angular项目从9.1.12升级到14.0.6有构建问题



在将angular项目从9.1.12升级到14.0.6之后,我通过运行npm run build构建项目后看到的错误:

npm run build                       
> gui@2.0.0 build C:projectsgui-components
> ng build
⠋ Generating browser application bundles (phase: setup)...Warning: Support was requested for Internet Explorer in the project's browserslist configuration. Internet Explorer is no longer officially supported.
For more information, see https://angular.io/guide/browser-support
✔ Browser application bundle generation complete.
./src/main.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Emit
./src/polyfills.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Emit
Error: Failed to initialize Angular compilation - The target entry-point "ngx-toastr" has missing dependencies:
- @angular/compiler/src/core
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gui@2.0.0 build: `ng build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gui@2.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersJulia.KabirianAppDataRoamingnpm-cache_logs2022-07-20T02_31_50_647Z-debug.log

这是我的包裹。json文件:

{
"name": "gui",
"version": "2.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"build:lib": "ng build gui-components --watch",
"build:docs": "ng build --configuration production  --base-href /content-app/",
"pack": "cd dist/@leapdev/gui-components && del *.tgz && npm pack",
"version": "echo %npm_package_version%"
},
"dependencies": {
"@angular/animations": "^14.0.6",
"@angular/common": "14.0.6",
"@angular/compiler": "14.0.6",
"@angular/core": "14.0.6",
"@angular/forms": "14.0.6",
"@angular/platform-browser": "14.0.6",
"@angular/platform-browser-dynamic": "14.0.6",
"@angular/router": "14.0.6",
"@leapdev/gui": "0.2.260",
"@leapdev/gui-components": "2.2.30",
"@leapdev/gui-icons": "2.0.28",
"@ng-select/ng-select": "4.0.4",
"bootstrap": "4.3.1",
"caniuse-lite": "^1.0.30001019",
"countries-list": "2.5.0",
"highlight.js": "^11.6.0",
"lite-server": "^2.5.4",
"lodash-es": "^4.17.21",
"moment": "^2.29.4",
"ng-inline-svg": "10.1.0",
"ngx-bootstrap": "6.2.0",
"ngx-highlightjs": "4.0.2",
"ngx-logger": "4.0.7",
"ngx-toastr": "^10.2.0",
"rxjs": "6.6.3",
"svg4everybody": "^2.1.9",
"tslib": "^2.0.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "14.0.6",
"@angular/cli": "14.0.6",
"@angular/compiler-cli": "14.0.6",
"@angular/language-service": "14.0.6",
"@types/jasmine": "~3.6.0",
"@types/jasminewd2": "2.0.8",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"ng-packagr": "^14.0.3",
"protractor": "~7.0.0",
"ts-node": "7.0.1",
"tsickle": "0.39.1",
"tslint": "~6.1.0",
"typescript": "4.6.4"
}
}

我尝试过的事情是删除node-modules并运行npm install。试了这个命令npm install ngx-toastr --save任何想法和想法将非常感激。运行npm ls @angular/core命令显示此错误:

PS C:UsersJulia.Kabirianprojectsgui-components> npm ls @angular/core
gui@2.0.0 C:UsersJulia.Kabirianprojectsgui-components
+-- UNMET PEER DEPENDENCY @angular/core@14.0.6 
`-- codelyzer@6.0.2
`-- @angular/core@9.0.0 
npm ERR! peer dep missing: @angular/core@9.*, required by @leapdev/gui-components@2.2.30
npm ERR! peer dep missing: @angular/core@>=9.0.0 <10.0.0, required by @ng-select/ng-select@4.0.4
npm ERR! peer dep missing: @angular/core@>=2.3.1 <13.0.0 || ^12.0.0-next || ^12.1.0-next || ^12.2.0-next, required by codelyzer@6.0.2
npm ERR! peer dep missing: @angular/core@^8.0.0, required by ngx-highlightjs@4.0.2
npm ERR! peer dep missing: @angular/core@^6.0.0 || ^7.0.0 || ^8.0.0, required by ngx-logger@4.0.7
npm ERR! peer dep missing: @angular/core@>=6.0.0 <9.0.0, required by ngx-toastr@10.2.0
我的节点版本是v14.15.1

你尝试过从Angular 9升级到Angular 10吗?

  1. 如果是,您是否看到任何错误?
  2. 如果没有,试着通过下面的命令
npx @angular/cli@10 update @angular/core@10 @angular/cli@10
  1. 然后运行应用程序。如果它可以工作,尝试升级到Angular 11,然后是12,等等
  2. https://update.angular.io/?v=9.1-10.0是您的朋友。它显示每个版本之间的详细变化。

专业提示:在一个版本迁移之后,如果某些东西不能工作,重新安装依赖项

$ rm -rf node_modules
$ npm i --force

您应该尝试删除node_modulespackage-lock.json,然后是npm install

您应该检查您的依赖项是否为最新版本->npm outdated.

您还可以检查您的Node版本。它应该在>=14.15.0和>=16.10.0之间。

手动升级到"ngx-toastr": "^13.2.1"解决ngx-toastr的问题polyfill的问题与这行代码import 'core-js/es/array';有关,因为我们不再支持IE删除了它。

最新更新