在webpack中找不到模块

时间:2020-01-31 15:59:27

标签: javascript node.js webpack

我正在使用npm install d3 --save并运行v5.15.0,它安装了const d3 = require('d3');

在我的一个脚本中,我使用以下命令导入d3:

//...more imports
const webpack = require('webpack');

module.exports = [{
    //...config stuff

    resolve:{},

    plugins: [
        // ...more modules
        new webpack.ProvidePlugin({ d3: 'd3',})
    ]
}]

webpack.config.js

ERROR in ./node_modules/d3-array/src/index.js
    Module not found: Error: Can't resolve './ascending' in '[work_dir]/node_modules/d3-array/src'
     @ ./node_modules/d3-array/src/index.js 2:0-49 2:0-49
     @ ./node_modules/d3/index.js
     @ ./src/index.js

 ~~ approx 1 billion more errors of the same kind

我遵循了这些two threads,结果错误消息如下:

array_count_values()

我也尝试了this solution,因为它看起来是相同的错误,但是没有运气。

1 个答案:

答案 0 :(得分:1)

通过在extensions: ['.js']的{​​{1}}属性中添加resolve来解决