首页 > 解决方案 > 无法解析“primeng/components/utils/ObjectUtils”

问题描述

我将我的项目从 angular 4 迁移到 angular 6,它在 localhost 上运行良好,但在 AOT-build 时出现如下错误:

ERROR in ./aot/app/home/accountant/customercost-form.component.ngfactory.ts
Module not found: Error: Can't resolve 'primeng/components/utils/ObjectUtils' in '/home/com5/Paresh/New Angular 6/AOT-6/aot/app/home/accountant'
 @ ./aot/app/home/accountant/customercost-form.component.ngfactory.ts 16:10-57
 @ ./aot/app/home/accountant/accounts.module.ngfactory.ts
 @ ./app/home/index.ts
 @ ./app/home/auth-guard.service.ts
 @ ./aot/app/app.module.ngfactory.ts
 @ ./app/main-aot.ts

ERROR in ./aot/app/home/accountant/vendorcost-form.component.ngfactory.ts
Module not found: Error: Can't resolve 'primeng/components/utils/ObjectUtils' in '/home/com5/Paresh/New Angular 6/AOT-6/aot/app/home/accountant'
 @ ./aot/app/home/accountant/vendorcost-form.component.ngfactory.ts 16:10-57
 @ ./aot/app/home/accountant/accounts.module.ngfactory.ts
 @ ./app/home/index.ts
 @ ./app/home/auth-guard.service.ts
 @ ./aot/app/app.module.ngfactory.ts
 @ ./app/main-aot.ts



ERROR in [at-loader] ./aot/app/app.module.ngfactory.ts:67:40 
    TS2339: Property 'ɵm' does not exist on type 'typeof import("/home/com5/Paresh/New Angular 6/AOT-6/node_modules/@angular/core/core")'.

我的 tsconfig-aot.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": ["es2015","es2017", "dom"],
    "noImplicitAny": true,
    "removeComments": true,
    "skipLibCheck": true,
    "suppressImplicitAnyIndexErrors": true,
    "typeRoots": [
      "node_modules/@types/"
    ],
    "outDir": "aot",
    "baseUrl": ".",
    "paths": {
      "@angular/*": ["node_modules/@angular/*"]
    }
  },
  "files": [
  ],
  "angularCompilerOptions": {
   "genDir": "aot",
   "skipMetadataEmit" : true
 }
}

包.json

{
  "name": "My-app",
  "version": "0.5.0",
  "scripts": {
    "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
    "build:aot": "node --max_old_space_size=6144 node_modules/.bin/ngc -p tsconfig-aot.json && node --max_old_space_size=6144 node_modules/.bin/rollup -c rollup-config.js",
    "lite:aot": "lite-server -c aot/bs-config.json",
    "e2e": "tsc && concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first",
    "lint": "tslint ./app/**/*.ts -t verbose",
    "lite": "lite-server",
    "pree2e": "webdriver-manager update",
    "test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
    "test-once": "tsc && karma start karma.conf.js --single-run",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "ngc": " node --max_old_space_size=6144 node_modules/.bin/ngc -p tsconfig-aot.json",
    "webpack-prod": " npm run ngc && npm run webpack",
    "webpack": "node --max_old_space_size=6144 node_modules/.bin/webpack ",
    "serve": "webpack-dev-server",
    "prodserver": "node prodserver"
  },
  "licenses": [
    {
      "type": "MIT",
      "url": "https://github.com/angular/angular.io/blob/master/LICENSE"
    }
  ],
  "dependencies": {
    "@angular/animations": "^6.1.10",
    "@angular/common": "^6.1.10",
    "@angular/compiler": "^6.1.10",
    "@angular/compiler-cli": "^6.1.10",
    "@angular/core": "^6.1.10",
    "@angular/forms": "^6.1.10",
    "@angular/http": "^6.1.10",
    "@angular/platform-browser": "^6.1.10",
    "@angular/platform-browser-dynamic": "^6.1.10",
    "@angular/platform-server": "^6.1.10",
    "@angular/router": "^6.1.10",
    "@angular/upgrade": "^6.1.10",
    "@auth0/angular-jwt": "^5.0.1",
    "@ngtools/webpack": "^1.1.2",
    "@types/googlemaps": "^3.2.0",
    "@types/jquery": "^2.0.48",
    "@types/jspdf": "^1.3.0",
    "@types/node": "8.0.0",
    "angular-in-memory-web-api": "^0.11.0",
    "angular2-busy": "^1.0.2",
    "angular2-datatable": "^0.5.3",
    "angular2-datatable-pagination": "0.0.3",
    "angular2-highcharts": "^0.5.5",
    "angular2-image-upload": "^0.3.1",
    "angular2-jwt": "^0.1.28",
    "angular2-moment": "^1.0.0-beta.rc.1",
    "angular2-multiselect-dropdown": "^2.9.0",
    "angular2-router-loader": "^0.3.5",
    "angular2-tag-input": "^1.2.3",
    "bootstrap": "^3.3.7",
    "bootstrap-datepicker": "^1.6.4",
    "bootstrap-daterangepicker": "^2.1.25",
    "bootstrap-timepicker": "^0.5.2",
    "chart.js": "^2.8.0",
    "core-js": "2.5.6",
    "css-toggle-switch": "^4.0.2",
    "express": "^4.15.3",
    "fullcalendar": "^3.0.1-beta",
    "highcharts": "7.1.1",
    "install": "^0.10.1",
    "lodash": "^4.17.11",
    "moment": "2.18.1",
    "mydatepicker": "^1.0.18",
    "ng2-bootstrap": "^1.1.16",
    "ng2-ckeditor": "1.2.0",
    "ng2-datetime": "^1.4.0",
    "ng2-device-detector": "^0.1.0",
    "ng2-file-upload": "^1.2.0",
    "ng2-imageupload": "^1.3.0",
    "ng2-select2": "^1.0.0-beta.11",
    "ng2-table": "^1.3.2",
    "ngx-barcode": "^0.2.4",
    "primeng": "^6.1.7",
    "primeui": "^4.1.15",
    "quill": "^1.3.0",
    "reflect-metadata": "^0.1.9",
    "rxjs": "6.3.2",
    "rxjs-compat": "^6.6.3",
    "rxjs-tslint": "^0.1.8",
    "screenfull": "4.0.1",
    "style-loader": "^0.17.0",
    "systemjs": "0.19.40",
    "tinymce": "^4.5.5",
    "to-string-loader": "^1.1.5",
    "tslib": "^2.0.1",
    "typings": "^2.1.1",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular/cli": "6.2.9",
    "@types/file-saver": "0.0.1",
    "@types/googlemaps": "^3.26.20",
    "@types/jquery": "^2.0.48",
    "@types/node": "7.0.7",
    "angular-router-loader": "^0.6.0",
    "angular2-template-loader": "0.6.2",
    "angular2-toaster": "^6.1.0",
    "awesome-typescript-loader": "3.1.3",
    "canonical-path": "0.0.2",
    "clean-webpack-plugin": "^0.1.16",
    "compression-webpack-plugin": "^0.4.0",
    "concurrently": "^3.0.0",
    "copy-webpack-plugin": "^4.0.1",
    "css-loader": "^0.28.1",
    "electron-packager": "^8.7.0",
    "extract-text-webpack-plugin": "^2.1.0",
    "favicons-webpack-plugin": "0.0.7",
    "file-loader": "^0.11.1",
    "html-loader": "^0.4.3",
    "html-webpack-plugin": "2.28.0",
    "http-server": "^0.10.0",
    "karma": "^5.2.2",
    "lite-server": "^2.2.2",
    "raw-loader": "^0.5.1",
    "rollup": "^0.41.6",
    "rollup-plugin-commonjs": "^8.0.2",
    "rollup-plugin-node-resolve": "^2.0.0",
    "rollup-plugin-uglify": "^1.0.1",
    "source-map-explorer": "^1.3.3",
    "typescript": "2.9.2",
    "webdriver-manager": "12.0.6",
    "webpack": "^2.5.1",
    "webpack-bundle-analyzer": "^2.8.1",
    "webpack-dev-server": "2.4.5"
  }
}

main-aot.ts

import { platformBrowser }    from '@angular/platform-browser';
import { AppModuleNgFactory } from '../aot/app/app.module.ngfactory';
import { enableProdMode } from '@angular/core';
enableProdMode();
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);

这是我所有的配置文件

标签: htmlangulartypescriptmigrationangular-aot

解决方案


不确定您是否遇到与我相同的问题,但是当我从 Angular 8 升级到 9(以及从 PrimeNG 8 到 9)时,我需要从“primeng/components/utils/ObjectUtils”更改 ObjectUtils 的导入路径只是“primeng/utils”。


推荐阅读