Angular 8-尝试服务应用程序时无法读取未定义的属性“ NODE_NDEBUG”

时间:2019-10-13 10:50:08

标签: javascript node.js angular typescript angular8

错误位于assert-plus库中的../node_modules/assert-plus/assert.js,在该处无法从“ process.env”读取“ NODE_NDEBUG”,如下面的代码片段所示

module.exports = _setExports(process.env.NODE_NDEBUG);

我最初遇到错误https://github.com/calvinmetcalf/crypto-pouch/issues/67 按照简单的说明操作后,错误消失了,这是我收到的下一个错误消息。

Uncaught TypeError: Cannot read property 'NODE_NDEBUG' of undefined
    at Object../node_modules/assert-plus/assert.js (assert.js:211)
    at __webpack_require__ (bootstrap:78)
    at Object../node_modules/http-signature/lib/parser.js (parser.js:3)
    at __webpack_require__ (bootstrap:78)
    at Object../node_modules/http-signature/lib/index.js (index.js:3)
    at __webpack_require__ (bootstrap:78)
    at Object../node_modules/request/request.js (request.js:11)
    at __webpack_require__ (bootstrap:78)
    at Object../node_modules/request/index.js (index.js:143)
    at __webpack_require__ (bootstrap:78)

这是我当前的polyfill.ts文件的快照

/***************************************************************************************************
 * APPLICATION IMPORTS
 */
(window as any) ['global'] = window;
(window as any).process = window;
(window as any).process.browser = true;
(window as any).process.version = '';
(window as any).process.versions = {node: false};
declare var global: any;
global.Buffer = global.Buffer || require('buffer').Buffer;

这是我的package.json的快照

{
  "name": "staysharpadmin",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~8.0.2",
    "@angular/cdk": "~8.0.2",
    "@angular/common": "~8.0.2",
    "@angular/compiler": "~8.0.2",
    "@angular/core": "~8.0.2",
    "@angular/forms": "~8.0.2",
    "@angular/material": "~8.0.2",
    "@angular/material-moment-adapter": "~8.0.1",
    "@angular/platform-browser": "~8.0.2",
    "@angular/platform-browser-dynamic": "~8.0.2",
    "@angular/router": "~8.0.2",
    "@fortawesome/angular-fontawesome": "^0.5.0",
    "@fortawesome/fontawesome-svg-core": "^1.2.25",
    "@fortawesome/free-solid-svg-icons": "^5.11.2",
    "@ng-bootstrap/ng-bootstrap": "^5.1.1",
    "ajv": "^6.10.2",
    "bluebird": "^3.7.0",
    "bootstrap": "^4.3.1",
    "core-js": "^2.5.4",
    "hammerjs": "^2.0.8",
    "jquery": "^3.4.1",
    "jstimezonedetect": "^1.0.6",
    "lodash": "^4.17.15",
    "moment": "^2.24.0",
    "moment-range": "^4.0.2",
    "moment-timezone": "^0.5.23",
    "popper.js": "^1.15.0",
    "pushy": "^2.0.8",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "request": "^2.88.0",
    "rxjs": "~6.5.2",
    "styled-components": "^4.3.2",
    "tslib": "^1.9.0",
    "twix": "^1.2.1",
    "web-animations-js": "^2.3.2",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.800.3",
    "@angular/cli": "8.0.3",
    "@angular/compiler-cli": "~8.0.2",
    "@angular/language-service": "~8.0.2",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^8.9.5",
    "codelyzer": "^5.1.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.4.0"
  },
  "browser": {
    "crypto": false,
    "http": false,
    "https": false,
    "os": false,
    "net": false,
    "path": false,
    "stream": false,
    "tls": false,
    "zlib": false,
    "fs": false
  }
}

我为应用程序提供服务后,浏览器就会显示一个白色的空白屏幕,当我检查页面时,我会看到如上所示的错误消息。任何建议将不胜感激。

1 个答案:

答案 0 :(得分:0)

默认情况下,Angular 8已经为该应用程序包括了polyfill,所以我认为您可以删除您的polyfill中的所有内容

如果这不起作用,也考虑将其用于您的polyfill

(window as any).global = window;