Angular 13 Webpack 异常:TypeError:无法读取未定义的属性(读取“NODE_DEBUG”)

Posted

技术标签:

【中文标题】Angular 13 Webpack 异常:TypeError:无法读取未定义的属性(读取“NODE_DEBUG”)【英文标题】:Angular 13 Webpack Exception: TypeError: Cannot read properties of undefined (reading 'NODE_DEBUG') 【发布时间】:2022-01-21 19:31:50 【问题描述】:

升级到 Angular 13 后,应用程序在运行时不再工作。从我读过的内容来看,NODE_DEBUG 是特定于 Webpack 的,由于某种原因,在使用“ng serve”运行应用程序时无法识别。我最近还升级到了 macOS Monterey。我现在很困....

package.json


    "dependencies": 
    "@angular-devkit/schematics": "^13.1.2",
    "@angular/animations": "~13.1.1",
    "@angular/cdk": "^13.1.0",
    "@angular/common": "~13.1.1",
    "@angular/compiler": "~13.1.1",
    "@angular/core": "~13.1.1",
    "@angular/fire": "^7.2.0",
    "@angular/forms": "~13.1.1",
    "@angular/material": "^13.1.0",
    "@angular/platform-browser": "~13.1.1",
    "@angular/platform-browser-dynamic": "~13.1.1",
    "@angular/router": "~13.1.1",
    "@angular/service-worker": "~13.1.1",
    "@costlydeveloper/ngx-awesome-popup": "^2.2.0",
    "@types/uuid": "^8.3.0",
    "buffer": "^6.0.3",
    "crypto-js": "^4.1.1",
    "firebase": "9.6.1",
    "jsonwebtoken": "^8.5.1",
    "jsstore": "4.3.6",
    "ngx-currency": "^2.5.2",
    "ramda": "^0.27.1",
    "rxjs": "~6.6.7",
    "service": "^0.1.4",
    "stream-browserify": "^3.0.0",
    "tslib": "^2.3.1",
    "util": "^0.12.4",
    "uuid": "^8.3.2",
    "zone.js": "~0.11.4"
  ,
  "devDependencies": 
    "@angular-devkit/architect": "0.1301.2",
    "@angular-devkit/build-angular": "^13.1.2",
    "@angular/cli": "~13.1.2",
    "@angular/compiler-cli": "~13.1.1",
    "@types/crypto-js": "^4.0.2",
    "@types/jasmine": "~3.6.0",
    "@types/jsonwebtoken": "8.5.4",
    "@types/node": "^16.11.2",
    "@types/ramda": "0.27.60",
    "codelyzer": "^6.0.2",
    "firebase-tools": "~9.23.1",
    "fuzzy": "^0.1.3",
    "inquirer": "^8.2.0",
    "inquirer-autocomplete-prompt": "^1.4.0",
    "jasmine-core": "~3.10.1",
    "jasmine-spec-reporter": "~7.0.0",
    "jsonc-parser": "^3.0.0",
    "karma": "~6.3.9",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "open": "^8.4.0",
    "protractor": "~7.0.0",
    "ts-node": "~10.4.0",
    "tslint": "~6.1.3",
    "typescript": "~4.5.3"

错误:

【问题讨论】:

【参考方案1】:

尝试删除您的 node_modules 文件夹并再次运行 npm install。

如果仍然无法正常工作,请尝试将节点版本降级到 12.20.x 并检查。

【讨论】:

不走运。不知道它是否与蒙特雷有关。我会尝试向下移动到 Angular 12【参考方案2】:

在将我的 Angular.json 与全新的 Angular 13 应用程序进行比较后,我进行了更新,以便它们在结构上匹配,因为 ng update 不能有效地处理这个问题。这导致我出现一个新错误,我发现 NODE_DEBUG 来自 utils.js,它是 jsonwebtoken 的依赖项。

【讨论】:

以上是关于Angular 13 Webpack 异常:TypeError:无法读取未定义的属性(读取“NODE_DEBUG”)的主要内容,如果未能解决你的问题,请参考以下文章

离子应用程序:发生未处理的异常:找不到模块“@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/uti

使用 Angular 13 for Electron 应用程序时如何升级 webpack 5?

角度:发生未处理的异常:找不到模块'webpack'?

Webpack Angular 4 编译需要很长时间

TS2304:在 Webpack / Angular 2 中找不到名称“描述”

我应该使用 Browserify 还是 Webpack 来延迟加载 Angular 1.x 中的依赖项 [关闭]