0

我尝试导入 Highcharts-更像这样:

import Highmore from '../../node_modules/highcharts/highcharts-more';

然后我得到以下错误:

Module '../../node_modules/highcharts/highcharts-more' was resolved to 'C:/Users/.../node_modules/highcharts/highcharts-more.js', but '--allowJs' is not set.

所以我进入我的 tsconfig.json 并将 allowJs 添加到我的设置中:

{
  "compilerOptions": {
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2015"
    ],
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es5"
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

之后我得到一个新的错误:

Cannot write file 'C:/Users/../node_modules/highcharts/highcharts-more.js' because it would overwrite input file.

我在整个项目中都需要 highcharts-more,但我找不到另一种导入它的方法。请帮忙

4

1 回答 1

0

使用与本文档( Typescript部分)中显示的语法相同的语法: https ://www.npmjs.com/package/highcharts

该示例是为导出模块完成的 - highcharts-more模块应该类推导入。

于 2018-01-16T13:00:44.573 回答