【问题标题】:升级到 Webpack 5 - TypeError: Cannot read property 'mkdir' of undefined
【发布时间】:2022-01-23 05:30:13
【问题描述】:

我目前正在从 webpack v4 迁移到 v5,我正在启动我的开发环境,我得到了

/../../../web/node_modules/webpack/lib/util/fs.js:200
    fs.mkdir(p, err => {
       ^

TypeError: Cannot read property 'mkdir' of undefined
    at mkdirp (/../../../web/node_modules/webpack/lib/util/fs.js:200:5)
    at /../../../web/node_modules/webpack/lib/Compiler.js:853:4
    at Hook.eval [as callAsync] (eval at create (/../../../web/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/../../../web/node_modules/tapable/lib/Hook.js:18:14)
    at Compiler.emitAssets (/../../../web/node_modules/webpack/lib/Compiler.js:850:19)
    at /../../../web/node_modules/webpack/lib/Compiler.js:438:10
    at processTicksAndRejections (internal/process/task_queues.js:77:11)

我已尝试将所有软件包升级/降级到当前版本,以及将节点从 v14 升级到 v15,但仍然遇到此错误。我已经尝试过webpack@5webpack-cli 的早期版本。我也有rm -rf node_modules & yarn.lock

【问题讨论】:

    标签: webpack vuejs2


    【解决方案1】:

    想通了。我有一个带有server.js 文件的快速服务器设置,在webpack 4 中,我的开发环境需要server.js 中的serverCompiler.outputFileSystem = devMiddleware.fileSystem;。我在 webpack 5 中不再需要这个,所以只需删除此行即可修复错误。

    【讨论】:

      猜你喜欢
      • 2021-06-25
      • 1970-01-01
      • 2017-04-24
      • 2023-03-15
      • 2017-09-23
      • 2023-02-22
      • 2021-09-18
      • 2021-09-25
      • 1970-01-01
      相关资源
      最近更新 更多