我正在尝试在 D3 之上构建一个小型 JS 库来绘制折线图。我对整个场景相当陌生,但我认为跳入“深渊”是最好的学习方式。
这是我的内容package.json
{
"name": "d3play02",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"d3-array": "^1.0.1",
"d3-axis": "^1.0.3",
"d3-request": "^1.0.2",
"d3-scale": "^1.0.3",
"d3-selection": "^1.0.2",
"d3-shape": "^1.0.3",
"d3-time-format": "^2.0.2",
"rollup": "^0.36.3",
"rollup-plugin-node-resolve": "^2.0.0",
"uglify-js": "^2.7.4"
},
"dependencies": {
"@types/d3": "^4.2.37"
}
}
我有一个名为LineChart.ts
在那里我有:
/// <reference path="node_modules/@types/d3/node_modules/@types/d3-request/index.d.ts" />
import csv from 'd3-request';
class LineChart {
data(url: string): DsvRequest {
// code to go here
}
}
但这给了我一个错误
它抱怨找不到d3-request
模块,但我已经安装了该模块,并且根据我读过的内容,我正确导入了!