首页 > 解决方案 > Ember 3.6.1 在升级后注入未知注入:'service:-document'

问题描述

所以我目前正在尝试更新我最初在版本 3.0.2 上的 EmberJS 应用程序。首先,我让应用程序在 3.2 上运行。然后我进一步升级并 Error: Assertion Failed: Attempting to inject an unknown injection: 'service:-document'在我的浏览器控制台中受到欢迎。

该应用程序使用成功构建,ember serve但我只在此错误旁边看到一个白屏,堆栈跟踪也绝对没用。唯一提到此类错误的是ember-wormhole旧 ember 版本上的 github 问题,我什至不在我的应用程序中使用此插件。我还意识到应用程序在app.js执行后某处死掉了,但我的初始化程序都没有被调用。

包.json:

"devDependencies": {
    "@babel/plugin-transform-block-scoping": "^7.8.3",
    "@sentry/browser": "^5.6.3",
    "@sentry/integrations": "^5.6.1",
    "broccoli-asset-rev": "^2.7.0",
    "ember-ajax": "^3.1.0",
    "ember-array-contains-helper": "^2.0.0",
    "ember-auto-import": "1.3.0",
    "ember-bootstrap": "^3.1.1",
    "ember-bootstrap-datepicker": "^2.0.1",
    "ember-changeset": "^2.2.4",
    "ember-changeset-validations": "^2.2.1",
    "ember-cli": "~3.6.1",
    "ember-cli-active-link-wrapper": "^0.5.0",
    "ember-cli-app-version": "^3.2.0",
    "ember-cli-babel": "^7.1.2",
    "ember-cli-code-coverage": "^0.4.1",
    "ember-cli-dependency-checker": "^3.0.0",
    "ember-cli-dependency-lint": "^1.0.2",
    "ember-cli-eslint": "^4.2.3",
    "ember-cli-htmlbars": "^4.2.2",
    "ember-cli-icon-rating": "^2.0.1",
    "ember-cli-inject-live-reload": "^1.8.2",
    "ember-cli-page-object": "^1.11.0",
    "ember-cli-sass": "^7.0.0",
    "ember-cli-sticky": "^0.6.4",
    "ember-cli-string-helpers": "^2.0.0",
    "ember-cli-template-lint": "^1.0.0-beta.1",
    "ember-cli-uglify": "^2.1.0",
    "ember-collapsible-panel": "^3.2.1",
    "ember-composable-helpers": "^2.0.1",
    "ember-confirm-dialog": "^1.3.0",
    "ember-countries": "^2.0.2",
    "ember-data": "~3.6.0",
    "ember-form-for-intl": "^1.0.6",
    "ember-i18n-iso-countries": "^1.5.0",
    "ember-keyboard": "^4.0.0",
    "ember-keycloak-auth": "~0.3.0",
    "ember-load-initializers": "^2.1.1",
    "ember-moment": "8.0.0",
    "ember-notify": "^5.2.0",
    "ember-pikaday": "2.4.1",
    "ember-power-select-with-create": "^0.6.0",
    "ember-qunit": "^3.4.1",
    "ember-resolver": "~5.3.0",
    "ember-route-action-helper": "^2.0.3",
    "ember-source": "~3.6.0",
    "ember-toggle": "^5.3.2",
    "eslint-config-prettier": "^4.3.0",
    "eslint-plugin-ember": "^5.2.0",
    "eslint-plugin-prettier": "^3.1.0",
    "husky": "^2.3.0",
    "keycloak-js": "^8.0.1",
    "lint-staged": "^8.1.7",
    "loader.js": "^4.7.0",
    "prettier": "1.17.1",
    "qunit-dom": "^0.8.0",
    "ui-ember-slider": "github:ifad/ui-slider",
    "watchman": "^1.0.0"
  },
  "engines": {
    "node": "6.* || 8.* || >= 10.*"
  },
  "dependencies": {
    "@babel/core": "7.8.4",
    "bootstrap": "^4.3.1",
    "bootstrap-slider": "^10.6.1",
    "ember-cli-update": "^0.27.1",
    "ember-intl": "^4.2.3",
    "global": "^4.4.0",
    "jquery": "^3.4.1",
    "npm": "^5.7.1",
    "popper.js": "^1.16.0",
    "to": "^0.2.9",
    "update": "^0.7.4"
  }

应用程序.js:

import Application from "@ember/application";
import RSVP from "rsvp";
import Resolver from "./resolver";
import loadInitializers from "ember-load-initializers";
import config from "./config/environment";
import $ from "jquery";

window.Promise = RSVP.Promise;

const App = Application.extend({
  modulePrefix: config.modulePrefix,
  podModulePrefix: config.podModulePrefix,
  Resolver
});

$.getJSON("/api/env_settings", function(envSettings) {
  config.sentryDsn = envSettings.sentry;
  config.keycloak.url = envSettings.keycloak.url;
  config.keycloak.realm = envSettings.keycloak.realm;
  config.keycloak.clientId = envSettings.keycloak.clientId;
  config.keycloak.secret = envSettings.keycloak.secret;
  config.helplink = envSettings.helplink;
  config.keycloak.disable = envSettings.keycloak.disable;
});

loadInitializers(App, config.modulePrefix);
export default App;

任何想法这个问题的原因在哪里?

快速更新:

我也尝试将我的应用程序直接升级到 3.15.2,这导致了同样的错误......

另一个更新:

堆栈跟踪如下所示:

Error: Assertion Failed: Attempting to inject an unknown injection: 'service:-document' vendor.js:54143:15
    assert http://localhost:4200/assets/vendor.js:54143
    validateInjections http://localhost:4200/assets/vendor.js:17702
    processInjections http://localhost:4200/assets/vendor.js:16916
    buildInjections http://localhost:4200/assets/vendor.js:16956
    injectionsFor http://localhost:4200/assets/vendor.js:16970
    create http://localhost:4200/assets/vendor.js:17036
    instantiateFactory http://localhost:4200/assets/vendor.js:16896
    _lookup http://localhost:4200/assets/vendor.js:16828
    processInjections http://localhost:4200/assets/vendor.js:16936
    buildInjections http://localhost:4200/assets/vendor.js:16956
    injectionsFor http://localhost:4200/assets/vendor.js:16970
    create http://localhost:4200/assets/vendor.js:17036
    instantiateFactory http://localhost:4200/assets/vendor.js:16896
    _lookup http://localhost:4200/assets/vendor.js:16828
    processInjections http://localhost:4200/assets/vendor.js:16936
    buildInjections http://localhost:4200/assets/vendor.js:16952
    injectionsFor http://localhost:4200/assets/vendor.js:16970
    create http://localhost:4200/assets/vendor.js:17036
    instantiateFactory http://localhost:4200/assets/vendor.js:16896
    _lookup http://localhost:4200/assets/vendor.js:16828
    lookup http://localhost:4200/assets/vendor.js:16666
    lookup http://localhost:4200/assets/vendor.js:45312
    getDOM http://localhost:4200/assets/vendor.js:163053
    updateDocumentLanguage http://localhost:4200/assets/vendor.js:163000
    set http://localhost:4200/assets/vendor.js:162810
    _set http://localhost:4200/assets/vendor.js:34139
    set http://localhost:4200/assets/vendor.js:34080
    CPSETTER_FUNCTION http://localhost:4200/assets/vendor.js:31584
    _set2 http://localhost:4200/assets/vendor.js:33493
    setLocale http://localhost:4200/assets/vendor.js:162946
    init http://localhost:4200/assets/vendor.js:162862
    superWrapper http://localhost:4200/assets/vendor.js:48884
    initialize http://localhost:4200/assets/vendor.js:47083
    create http://localhost:4200/assets/vendor.js:47667
    create http://localhost:4200/assets/vendor.js:17092
    instantiateFactory http://localhost:4200/assets/vendor.js:16896
    _lookup http://localhost:4200/assets/vendor.js:16828
    lookup http://localhost:4200/assets/vendor.js:16666
    initialize http://localhost:4200/assets/frontend.js:8767
    runInitializers http://localhost:4200/assets/vendor.js:54873
    each http://localhost:4200/assets/vendor.js:73443
    walk http://localhost:4200/assets/vendor.js:73357
    each http://localhost:4200/assets/vendor.js:73287
    topsort http://localhost:4200/assets/vendor.js:73295
    _runInitializer http://localhost:4200/assets/vendor.js:54899
    runInitializers http://localhost:4200/assets/vendor.js:54871
    _bootSync http://localhost:4200/assets/vendor.js:53180
    domReady http://localhost:4200/assets/vendor.js:53080
    _run http://localhost:4200/assets/vendor.js:72991
    _join http://localhost:4200/assets/vendor.js:72967
    join http://localhost:4200/assets/vendor.js:72684
    join http://localhost:4200/assets/vendor.js:59338
    bind http://localhost:4200/assets/vendor.js:59442
    mightThrow http://localhost:4200/assets/vendor.js:9158
    process http://localhost:4200/assets/vendor.js:9226

使用ember-inspector该应用程序的工作 3.2 版本,我试图在ember-inspector. 很遗憾,我也找不到那里的服务......

标签: javascriptember.js

解决方案


正如@Lux 所说,堆栈跟踪是关键点。有一个initialize函数调用了一个ember-form-for-intl在那个版本上被破坏的函数。因此,我刚刚将其删除并使其正常工作。

非常感谢!!


推荐阅读