Окно не определено в угловой сборке с использованием библиотеки onsen-ui

Я получаю, что окно не определено при попытке создать мое угловое прогрессивное веб-приложение. Я получаю следующий стек и уже пытался обновить onsen-i

Ниже приведен мой стек ошибок:

Unhandled Promise rejection: window is not defined ; Zone: <root> ; Task: Promise.then ; Value: ReferenceError: window is not defined
at /Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:238922:16
at /Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:238928:2
at /Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:238892:27
at Object../node_modules/onsenui/js/onsenui.js (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:238894:2)
at __webpack_require__ (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:20:30)
at webpackUniversalModuleDefinition (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:235164:239)
at Object../node_modules/ngx-onsenui/__ivy_ngcc__/bundles/ngx-onsenui.umd.js (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:235166:3)
at __webpack_require__ (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:20:30)
at Object../src/app/app.module.ts (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:283887:23)
at __webpack_require__ (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:20:30)
at Object../src/app/app.server.module.ts (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:284112:22)
at __webpack_require__ (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:20:30)
at Object../src/main.server.ts (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:288225:27)
at __webpack_require__ (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:20:30)
at Object.0 (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:288241:18)
at __webpack_require__ (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:20:30) ReferenceError: window is not defined
at /Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:238922:16
at /Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:238928:2
at /Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:238892:27
at Object../node_modules/onsenui/js/onsenui.js (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:238894:2)
at __webpack_require__ (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:20:30)
at webpackUniversalModuleDefinition (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:235164:239)
at Object../node_modules/ngx-onsenui/__ivy_ngcc__/bundles/ngx-onsenui.umd.js (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:235166:3)
at __webpack_require__ (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:20:30)
at Object../src/app/app.module.ts (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:283887:23)
at __webpack_require__ (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:20:30)
at Object../src/app/app.server.module.ts (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:284112:22)
at __webpack_require__ (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:20:30)
at Object../src/main.server.ts (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:288225:27)
at __webpack_require__ (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:20:30)
at Object.0 (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:288241:18)
at __webpack_require__ (/Users/talesmarinho/projetos/scheduling/scheduling-pwa/dist/my-app/server/main.js:20:30)window is not defined

И вот мой package.json:

{
  "name": "scheduling-pwa",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --open",
    "dev": "ng serve --host 0.0.0.0",
    "build": "ng run my-app:app-shell",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~9.0.0",
    "@angular/cdk": "^9.2.2",
    "@angular/common": "~9.0.0",
    "@angular/compiler": "~9.0.0",
    "@angular/core": "~9.0.0",
    "@angular/flex-layout": "^9.0.0-beta.29",
    "@angular/forms": "~9.0.0",
    "@angular/localize": "^9.1.6",
    "@angular/material": "^9.2.2",
    "@angular/platform-browser": "~9.0.0",
    "@angular/platform-browser-dynamic": "~9.0.0",
    "@angular/platform-server": "~9.0.0",
    "@angular/router": "~9.0.0",
    "@angular/service-worker": "~9.0.0",
    "@ngrx/component": "github:ngrx/component-builds.git",
    "@ngrx/effects": "^9.2.0",
    "@ngrx/entity": "^9.2.0",
    "@ngrx/router-store": "^9.1.2",
    "@ngrx/schematics": "^9.2.0",
    "@ngrx/store": "^9.2.0",
    "@ngrx/store-devtools": "^9.2.0",
    "@ngx-translate/core": "^12.1.2",
    "@ngx-translate/http-loader": "^4.0.0",
    "date-fns": "^2.15.0",
    "domino": "^2.1.6",
    "ngx-device-detector": "^1.4.2",
    "ngx-ellipsis": "^2.3.1",
    "ngx-material-timepicker": "^5.5.3",
    "ngx-onsenui": "^7.0.0",
    "ngx-toastr": "^12.1.0",
    "onsenui": "^2.10.10",
    "rxjs": "~6.5.0",
    "tslib": "^1.11.2",
    "zone.js": "~0.10.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.900.0",
    "@angular/cli": "~9.0.0",
    "@angular/compiler-cli": "~9.0.0",
    "@angular/language-service": "~9.0.0",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~12.11.0",
    "@typescript-eslint/eslint-plugin": "^3.3.0",
    "@typescript-eslint/parser": "^3.3.0",
    "codelyzer": "~5.2.0",
    "eslint": "^7.2.0",
    "eslint-config-prettier": "^6.11.0",
    "eslint-plugin-prettier": "^3.1.4",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~4.2.0",
    "karma": "~4.4.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~2.1.0",
    "karma-jasmine": "~3.1.0",
    "karma-jasmine-html-reporter": "~1.5.0",
    "prettier": "^2.0.5",
    "prettier-eslint": "^11.0.0",
    "protractor": "~5.4.0",
    "ts-node": "~8.8.0",
    "tslint": "~6.1.0",
    "typescript": "~3.7.0"
  }
}

Я уже просмотрел следующие ссылки и все еще не могу решить свою проблему =/

Как исправить ошибку "ReferenceError: окно не определено" в angular 6 universal server.js

https://github.com/angular/universal/issues/830

https://github.com/angular/universal/issues/830

Похоже, это происходит при компиляции файла ngx-onsenui.

В настоящее время я пробовал этот подход https://github.com/angular/universal/issues/830. Но все равно не работает. Есть у кого-нибудь идеи, как это решить?

0 ответов

Другие вопросы по тегам