【问题标题】:Laravel npm run dev returns TypeError: chunk.sortModules is not a functionLaravel npm run dev 返回 TypeError: chunk.sortModules 不是函数
【发布时间】:2018-06-15 10:55:39
【问题描述】:

当我尝试运行 npm run dev 时,我收到此错误。这是一个全新的安装,我让它在另一个文件夹中使用相同的设置。我在另一台计算机上遇到同样的错误。

版本 NPM:5.3.0 节点:v8.4.0

test ⚑ → npm run dev                                                                                                                                                                                                                                                        master ✗ 2d

> @ dev /Users/myuser/Code/testing/test
> node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

 78% advanced chunk optimization/Users/myuser/Code/testing/test/node_modules/extract-text-webpack-plugin/dist/index.js:188
            chunk.sortModules();
                  ^

TypeError: chunk.sortModules is not a function
    at /Users/myuser/Code/testing/test/node_modules/extract-text-webpack-plugin/dist/index.js:188:19
    at /Users/myuser/Code/testing/test/node_modules/async/dist/async.js:3083:16
    at eachOfArrayLike (/Users/myuser/Code/testing/test/node_modules/async/dist/async.js:1003:9)
    at eachOf (/Users/myuser/Code/testing/test/node_modules/async/dist/async.js:1051:5)
    at Object.eachLimit (/Users/myuser/Code/testing/test/node_modules/async/dist/async.js:3145:5)
    at Compilation.<anonymous> (/Users/myuser/Code/testing/test/node_modules/extract-text-webpack-plugin/dist/index.js:184:27)
    at Compilation.applyPluginsAsyncSeries (/Users/myuser/Code/testing/test/node_modules/tapable/lib/Tapable.js:206:13)
    at Compilation.seal (/Users/myuser/Code/testing/test/node_modules/webpack/lib/Compilation.js:579:8)
    at /Users/myuser/Code/testing/test/node_modules/webpack/lib/Compiler.js:493:16
    at /Users/myuser/Code/testing/test/node_modules/tapable/lib/Tapable.js:289:11
    at _addModuleChain (/Users/myuser/Code/testing/test/node_modules/webpack/lib/Compilation.js:481:11)
    at processModuleDependencies.err (/Users/myuser/Code/testing/test/node_modules/webpack/lib/Compilation.js:452:13)
    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! @ dev: `node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev 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/myuser/.npm/_logs/2017-09-04T13_55_30_770Z-debug.log

【问题讨论】:

    标签: laravel npm laravel-mix


    【解决方案1】:

    这个问题似乎与包的差异有关,就在今天我正在更新 webapacker 版本 3,它在 rails 应用程序中使用 webpack 版本 3,我遇到了同样的错误。当我在 package.json 文件中将此软件包更新为此版本时,问题停止了: "sass-loader": "^6.0.6" "babel-loader": "7.1.2" "webpack": "^3.6.0" 感谢这家伙的建议:https://github.com/rails/webpacker/issues/852#issuecomment-331764386 我建议如果您正在使用这些软件包,请更改为这些版本,看看它是否也适合您。

    【讨论】:

    • 我也遇到了同样的问题,你的回答是正确的
    【解决方案2】:

    这对我有用。当我改用 Yarn 时。

    rm -rf node_modules
    brew install yarn
    yarn
    yarn run dev
    

    【讨论】:

      【解决方案3】:

      首先,删除webpack 插件。然后使用以下步骤安装和构建yarn

      1. npm install remove-webpack-plugin --save-dev
      2. yarn install
      3. yarn build

      【讨论】:

        猜你喜欢
        • 2023-02-03
        • 2020-11-25
        • 2020-12-15
        • 2022-12-20
        • 2019-02-10
        • 2022-08-02
        • 2021-07-18
        • 2021-01-31
        • 2022-07-21
        相关资源
        最近更新 更多