本文介绍了Webpack:收到此错误:构建失败(来自 ./node_modules/css-loader/dist/cjs.js):的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行 Webpack 时,出现以下错误:

When running Webpack, I get the following error:

./src/css/main.css 3.62 KiB {0} [不可缓存] [构建] [失败] [1 个错误]

./src/css/main.css 3.62 KiB {0} [not cacheable] [built] [failed] [1 error]

./src/css/main.css 中的错误模块构建失败(来自 ./node_modules/css-loader/dist/cjs.js):...accumulator[normalizedUrl] = { ...accumulator[normalizedUrl],^^^...

ERROR in ./src/css/main.cssModule build failed (from ./node_modules/css-loader/dist/cjs.js):... accumulator[normalizedUrl] = { ...accumulator[normalizedUrl], ^^^...

webpack.config.js:

webpack.config.js:

    module: {
      rules: [
        {
         test: /\.css$/i,
         use: ['css-loader']
        }
      ]
    }

CSS:

    body {
      background-color:purple;
    }

js:

    import css from '../css/main.css';

在js文件上,如果我输入

on js file, if I enter

    import '../css/main.css';

我遇到了同样的错误.

非常感谢您的帮助.

推荐答案

通过升级节点解决了问题.

Resolved the issue by upgrading node.

这篇关于Webpack:收到此错误:构建失败(来自 ./node_modules/css-loader/dist/cjs.js):的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 05:26