ember.js 导入d3时出错?

uujelgoq  于 2022-11-23  发布在  其他
关注(0)|答案(1)|浏览(159)

我是d3的新手,正在尝试创建一个线图。我似乎不能正确地导入它,但是,我得到了这个错误。我正在使用EmberJS,但我不知道这是否相关。

Could not find module `d3` imported from 'filepath'.

这是我的档案:

import Component from '@ember/component';
import { computed } from '@ember/object';
import * as d3 from 'd3';

d3.json('URL');

export default class ComponentName extends Component {
}

我已经做过很多次npm installnpm ci,这些相关的模块在我的package.json

"devDependencies": {
        "@types/d3": "^5.16.3",
        "d3": "^6.2.0",
    }

我安装的其他模块似乎不太相关:

"devDependencies": {
        "@ember/optional-features": "^2.0.0",
        "@glimmer/component": "^1.0.1",
        "@glimmer/tracking": "^1.0.1",
        "@types/ember": "^3.16.1",
        "@types/ember-qunit": "^3.4.12",
        "@types/ember-resolver": "^5.0.10",
        "@types/ember-test-helpers": "^1.0.4",
        "@types/ember-testing-helpers": "0.0.3",
        "@types/ember__array": "3.0.4",
        "@types/ember__test-helpers": "^1.7.3",
        "@types/qunit": "^2.9.5",
        "@types/rsvp": "^4.0.2",
        "@types/sinon": "^7.0.0",
        "@typescript-eslint/eslint-plugin": "^1.11.0",
        "@typescript-eslint/parser": "^1.11.0",
        "babel-eslint": "^10.1.0",
        "broccoli-asset-rev": "^3.0.0",
        "ember-ajax": "^3.1.0",
        "ember-auto-import": "^1.6.0",
        "ember-cli": "~3.21.2",
        "ember-cli-dependency-checker": "^3.2.0",
        "ember-cli-htmlbars-inline-precompile": "^1.0.3",
        "ember-cli-inject-live-reload": "^2.0.2",
        "ember-cli-sri": "^2.1.1",
        "ember-cli-template-lint": "^1.0.0-beta.1",
        "ember-cli-terser": "^4.0.0",
        "ember-cli-typescript-blueprints": "^3.0.0",
        "ember-cli-uglify": "^2.1.0",
        "ember-disable-prototype-extensions": "^1.1.3",
        "ember-export-application-global": "^2.0.1",
        "ember-load-initializers": "^2.1.1",
        "ember-maybe-import-regenerator": "^0.1.6",
        "ember-qunit": "^4.6.0",
        "ember-resolver": "^8.0.2",
        "ember-sinon": "^4.0.0",
        "ember-sinon-qunit": "^3.4.0",
        "ember-source": "~3.21.1",
        "ember-source-channel-url": "^3.0.0",
        "ember-template-lint": "^2.11.0",
        "ember-try": "^1.4.0",
        "eslint": "^5.16.0",
        "eslint-config-prettier": "^5.0.0",
        "eslint-plugin-ember": "^8.13.0",
        "eslint-plugin-node": "^11.1.0",
        "eslint-plugin-prettier": "^3.1.0",
        "eslint-plugin-security": "^1.4.0",
        "loader.js": "^4.7.0",
        "npm-run-all": "^4.1.5",
        "prettier": "^1.18.2",
        "qunit-dom": "^1.4.0",
        "semantic-release": "^15.13.16",
        "sinon": "^7.2.2",
        "typescript": "^4.0.3"
}

这是我的tsconfig.json

{
    "extends": "some-custom-config",
    "compilerOptions": {
      "inlineSourceMap": true,
      "inlineSources": true,
      "baseUrl": ".",
      "module": "es6",
      "paths": {
        "*": [
          "types/*"
        ]
      }
    },
    "include": [
      "app/**/*",
      "addon/**/*",
      "tests/**/*",
      "types/**/*",
      "test-support/**/*",
      "addon-test-support/**/*"
    ]
  }
w7t8yxp5

w7t8yxp51#

原来需要一个名为“ember-d3”的模块才能将d3与ember一起使用。

相关问题