本机脚本:升级后无法读取未定义的属性“ 0”:Angular 10

时间:2020-09-19 20:35:49

标签: webpack nativescript

升级Angular 10后出现以下错误:

ERROR in Cannot read property '0' of undefined
Error: Executing webpack failed with exit code 2.
    at WebpackCompilerService.<anonymous> (/usr/local/lib/node_modules/nativescript/lib/services/webpack/webpack-compiler-service.js:141:43)
    at Generator.next (<anonymous>)
    at fulfilled (/usr/local/lib/node_modules/nativescript/lib/services/webpack/webpack-compiler-service.js:11:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)

在文件webpack-compiler-service.js的此处失败:

childProcess.on("close", (arg) => __awaiter(this, void 0, void 0, function* () {
    yield this.$cleanupService.removeKillProcess(childProcess.pid.toString());
    delete this.webpackProcesses[platformData.platformNameLowerCase];
    const exitCode = typeof arg === "number" ? arg : arg && arg.code;
    if (exitCode === 0) {
        resolve();
    }
    else {
        const error = new Error(`Executing webpack failed with exit code ${exitCode}.`);
        error.code = exitCode;
        reject(error);
    }

这是我的package.json

{
  "scripts": {
    "clean": "npx rimraf hooks node_modules package-lock.json platforms",
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "android": "tns run android --no-hmr",
    "ios": "tns run ios --no-hmr",
    "mobile": "tns run",
    "preview": "tns preview",
    "ngcc": "ngcc --properties es2015 module main --first-only",
    "postinstall": "npm run ngcc"
  },
  "dependencies": {
    "@angular/animations": "~10.0.0",
    "@angular/common": "~10.0.0",
    "@angular/compiler": "~10.0.0",
    "@angular/core": "~10.0.0",
    "@angular/forms": "~10.0.0",
    "@angular/localize": "^10.0.7",
    "@angular/http": "8.0.0-beta.10",
    "@angular/platform-browser": "~10.0.0",
    "@angular/platform-browser-dynamic": "~10.0.0",
    "@angular/router": "~10.0.0",
    "@nativescript/angular": "~10.0.0",
    "@nativescript/core": "7.0.3",
    "@nstudio/nativescript-loading-indicator": "1.0.0",
    "@types/lodash": "^4.14.110",
    "@types/node": "^14.0.4",
    "bignumber.js": "^9.0.0",
    "crypto-js": "^3.1.9-1",
    "growl": "^1.10.2",
    "lodash": "^4.17.10",
    "moment": "^2.22.2",
    "nativescript": "6.7.4",
    "nativescript-app-sync": "1.0.7",
    "nativescript-carousel": "~7.0.1",
    "nativescript-couchbase": "1.0.18",
    "nativescript-filterable-listpicker": "2.2.6",
    "nativescript-localize": "4.2.0",
    "nativescript-modal-datetimepicker": "1.2.0",
    "nativescript-theme-core": "~1.0.6",
    "nativescript-toasty": "3.0.0-alpha.2",
    "nativescript-ui-autocomplete": "6.0.0",
    "nativescript-ui-chart": "8.0.2",
    "nativescript-ui-highcharts": "^1.2.0",
    "nativescript-ui-listview": "9.0.2",
    "nativescript-unit-test-runner": "0.7.0",
    "reflect-metadata": "~0.1.12",
    "rxjs": "~6.5.5",
    "rxjs-tslint": "^0.1.8",
    "zone.js": "~0.10.2",
    "core-js": "^2.6.9",
    "@nativescript/theme": "~2.2.1",
    "tslib": "1.10.0",
    "@nativescript/webpack": "3.0.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1000.2",
    "@angular/cli": "~10.0.0",
    "@angular/compiler-cli": "~10.0.0",
    "@nativescript/android": "~7.0.0",
    "@nativescript/ios": "7.0.0",
    "@nativescript/tslint-rules": "~0.0.5",
    "@nativescript/types": "7.0.0",
    "@types/crypto-js": "^3.1.43",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "@typescript-eslint/eslint-plugin": "^2.28.0",
    "@typescript-eslint/parser": "^2.28.0",
    "babel-traverse": "6.26.0",
    "babel-types": "6.26.0",
    "babylon": "6.18.0",
    "codelyzer": "^5.1.2",
    "eslint": "^6.8.0",
    "husky": "^0.14.3",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.4.1",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~2.1.0",
    "karma-jasmine": "~3.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "karma-nativescript-launcher": "0.4.0",
    "karma-webpack": "3.0.5",
    "lazy": "1.0.11",
    "lint-staged": "^7.2.0",
    "node-sass": "^4.7.1",
    "prettier": "^1.13.7",
    "protractor": "~5.4.3",
    "ts-node": "~8.3.0",
    "tslib": "~1.10.0",
    "tslint": "~6.1.0",
    "typescript": "~3.9.0"
  },
  "main": "main.js",
  "author": "",
  "description": "",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>"
}

我尝试清理挂钩,平台,package-lock.json,尝试迁移,安装/重新安装webpack和nativescript / webpack,但这总是导致此错误。

是否还有其他堆栈可以追踪错误的堆栈?它失败并出现一般错误。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我实际上使它工作了,问题似乎与所使用的angular,nativescript和webpack的版本有关。

对我来说,它适用于:所有与角度相关的东西,包括@ nativescript / angular,版本均为“ 10.1.5”,“ @ ngtools / webpack”:“〜10.1.6”和“ @ nativescript / webpack”:“ 〜3.0.7“

玩得开心!