Cannot find module 'webpack-merge' 怎么解决?

照着官网文档做了个合并配置。npm run dev。
但是爆了Cannot find module 'webpack-merge'错误。run build也一样报错

clipboard.png

以下是我的配置,简单的狠,谁能帮我看下。谢谢
【package.json】

"scripts": {
   "test": "echo \"Error: no test specified\" && exit 1",
   "build": "webpack --config webpack.prod.js",
   "dev": "webpack-dev-server --open --config webpack.dev.js"
}

【webpack.dev.js】

const Merge = require('webpack-merge');
const CommonConfig = require('./webpack.common.js');

module.exports = Merge(CommonConfig, {
    devtool: 'inline-source-map'
});

【webpack.common.js】

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');

module.exports = {
    entry: {
        app: './src/index.js'
    },
    output: {
        filename: '[name].bundle.js',
        path: path.resolve(__dirname, 'dist')
    },
    plugins: [
        new CleanWebpackPlugin(['dist']),
        new HtmlWebpackPlugin({
            title: 'Output Management'
        })
    ],
    module: {
        rules: [{
                test: /\.css$/,
                use: [
                    'style-loader',
                    'css-loader'
                ]
            },
            {
                test: /\.(png|svg|jpg|gif)$/,
                use: ['file-loader']
            }
        ]
    }
};
阅读 24.1k
1 个回答

找不到这个模块 webpack-merge
执行 npm install webpack-merge -D 安装即可

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题