在webpack中找不到模块

问题描述 投票:0回答:1

我正在使用webpack 4.41.5并运行npm install d3 --save,该安装了v5.15.0

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

const d3 = require('d3');

webpack.config.js

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

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

    resolve:{},

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

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

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

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

javascript node.js webpack
1个回答
0
投票

通过在extensions: ['.js']resolve属性中添加webpack.config.js解决

© www.soinside.com 2019 - 2024. All rights reserved.