【问题标题】:Chunk.entrypoints: Use Chunks.groupsIterable and filter by instanceof Entrypoint insteadChunk.entrypoints:使用 Chunks.groupsIterable 并通过 instanceof Entrypoint 过滤
【发布时间】:2018-12-25 06:54:20
【问题描述】:

我在尝试启动我的应用程序时看到以下错误...

> css-modules@1.0.0 start /Users/johnnynolan/Repos/css-modules

webpack && 打开 index.html

(node:5706) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
/Users/johnnynolan/Repos/css-modules/node_modules/webpack/lib/Chunk.js:802
        throw new Error(
        ^

Error: Chunk.entrypoints: Use Chunks.groupsIterable and filter by instanceof Entrypoint instead
    at Chunk.get (/Users/johnnynolan/Repos/css-modules/node_modules/webpack/lib/Chunk.js:802:9)
    at /Users/johnnynolan/Repos/css-modules/node_modules/extract-text-webpack-plugin/dist/index.js:176:48
    at Array.forEach (<anonymous>)
    at /Users/johnnynolan/Repos/css-modules/node_modules/extract-text-webpack-plugin/dist/index.js:171:18
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/johnnynolan/Repos/css-modules/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:7:1)
    at AsyncSeriesHook.lazyCompileHook [as _callAsync] (/Users/johnnynolan/Repos/css-modules/node_modules/tapable/lib/Hook.js:35:21)
    at Compilation.seal (/Users/johnnynolan/Repos/css-modules/node_modules/webpack/lib/Compilation.js:1203:27)
    at hooks.make.callAsync.err (/Users/johnnynolan/Repos/css-modules/node_modules/webpack/lib/Compiler.js:547:17)
    at _err0 (eval at create (/Users/johnnynolan/Repos/css-modules/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:11:1)
    at _addModuleChain (/Users/johnnynolan/Repos/css-modules/node_modules/webpack/lib/Compilation.js:1054:12)
    at processModuleDependencies.err (/Users/johnnynolan/Repos/css-modules/node_modules/webpack/lib/Compilation.js:980:9)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! css-modules@1.0.0 start: `webpack && open index.html`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the css-modules@1.0.0 start script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /Users/johnnynolan/.npm/_logs/2018-07-17T14_04_42_021Z-debug.log

【问题讨论】:

  • css-modules 可能会抛出一些东西。发布整个堆栈跟踪和您的 webpack 配置
  • 我建议您将问题编辑为更多类似“我该如何解决这个问题?”的内容。而不是“有人见过这个吗?”
  • extract-text-plugin 不适用于 Webpack v4

标签: javascript npm webpack


【解决方案1】:

这里的大多数 cmets https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/701 指向extract-text-plugin 改为mini-css-extract-plugin

来自extract-text-webpack-pluginhttps://github.com/webpack-contrib/extract-text-webpack-plugin的Github repo

⚠️ 由于 webpack v4 不应该使用 extract-text-webpack-plugin 对于 CSS。请改用 mini-css-extract-plugin。

前往 mini-css-extract-plugin 关于如何交换/升级它 https://github.com/webpack-contrib/mini-css-extract-plugin

【讨论】:

    【解决方案2】:
    npm install extract-text-webpack-plugin@next
    

    这对我有用!

    【讨论】:

    • @next 给我带来了“^4.0.0-beta.0”,正是我所需要的。谢谢。
    【解决方案3】:

    我已经使用extract-text-webpack-plugin4.0.0-beta.0 版本修复了这个错误。

    【讨论】:

    • 更新到 4.0.0-beta.0 也解决了我的问题
    • VS Code 没有针对 4.x 的自动完成功能,因此感谢您为我节省了另一个具有显式版本的谷歌搜索。
    • 那是什么路径?
    【解决方案4】:

    是的,我在使用 webpack 4.10.2 时遇到了同样的问题。将extract-css-chunks-webpack-plugin 换成mini-css-extract-plugin 后问题得到解决。

    这是 webpack 配置更改:

    -const ExtractCssChunks = require('extract-css-chunks-webpack-plugin')
    +const MiniCssExtractPlugin = require("mini-css-extract-plugin");
    
    module.exports = {
      name: 'client',
      target: 'web',
      module: {
        rules: [
          {
            test: /\.css$/,
    -       use: ExtractCssChunks.extract({
    -         use: 'css-loader'
    -       })
    +       use: [
    +         {
    +           loader: MiniCssExtractPlugin.loader,
    +         },
    +         "css-loader"
    +       ]
          }
        ]
      },
    // 
    // other config........
    //
       plugins: [
    -    new ExtractCssChunks(),
    +    new MiniCssExtractPlugin({
    +        filename: `components/[name].css`
    +    }),
         //
         // other config........
         //
       ]
    
    

    希望对你有帮助。

    【讨论】:

    • 它确实比上述答案更有帮助。谢谢。
    猜你喜欢
    • 2019-01-09
    • 1970-01-01
    • 1970-01-01
    • 2018-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-16
    • 1970-01-01
    相关资源
    最近更新 更多