【问题标题】:Webpack hot reloading ENOENT no such file or directoryWebpack 热重载 ENOENT 没有这样的文件或目录
【发布时间】:2017-03-27 04:57:35
【问题描述】:

我在 Windows 上使用 Ubuntu。我克隆了一个新的react-redux-starter-kitreact-redux-universal-hot-example 和我自己的实现也存在同样的问题。

npm install 之后,我用npm start 启动了服务器,页面运行良好。

编辑文件后,我收到以下错误:

Unhandled rejection Error: Module build failed: Error: ENOENT: no such file or directory, open '/mnt/c/Users/xxx/WebstormProjects/react-redux-starter-kit/src/main.js'
  at Error (native)
  at Compiler.<anonymous> (/mnt/c/Users/xxx/WebstormProjects/react-redux-starter-kit/build/webpack.config.js:69:15)
  at Compiler.applyPlugins (/mnt/c/Users/xxx/WebstormProjects/react-redux-starter-kit/node_modules/tapable/lib/Tapable.js:26:37)
  at Watching._done (/mnt/c/Users/xxx/WebstormProjects/react-redux-starter-kit/node_modules/webpack/lib/Compiler.js:78:17)
  at Watching.<anonymous> (/mnt/c/Users/xxx/WebstormProjects/react-redux-starter-kit/node_modules/webpack/lib/Compiler.js:51:17)
  at /mnt/c/Users/xxx/WebstormProjects/react-redux-starter-kit/node_modules/webpack/lib/Compiler.js:403:12
  at Compiler.next (/mnt/c/Users/xxx/WebstormProjects/react-redux-starter-kit/node_modules/tapable/lib/Tapable.js:67:11)
  at Compiler.<anonymous> (/mnt/c/Users/xxx/WebstormProjects/react-redux-starter-kit/node_modules/webpack/lib/CachePlugin.js:40:4)
  at Compiler.applyPluginsAsync (/mnt/c/Users/xxx/WebstormProjects/react-redux-starter-kit/node_modules/tapable/lib/Tapable.js:71:13)
  at Compiler.<anonymous> (/mnt/c/Users/xxx/WebstormProjects/react-redux-starter-kit/node_modules/webpack/lib/Compiler.js:400:9)
  at Compilation.<anonymous> (/mnt/c/Users/xxx/WebstormProjects/react-redux-starter-kit/node_modules/webpack/lib/Compilation.js:577:13)
  at Compilation.applyPluginsAsync (/mnt/c/Users/xxx/WebstormProjects/react-redux-starter-kit/node_modules/tapable/lib/Tapable.js:60:69)
  at Compilation.<anonymous> (/mnt/c/Users/xxx/WebstormProjects/react-redux-starter-kit/node_modules/webpack/lib/Compilation.js:572:10)
  at Compilation.applyPluginsAsync (/mnt/c/Users/xxx/WebstormProjects/react-redux-starter-kit/node_modules/tapable/lib/Tapable.js:60:69)
  at Compilation.<anonymous> (/mnt/c/Users/xxx/WebstormProjects/react-redux-starter-kit/node_modules/webpack/lib/Compilation.js:567:9)
  at Compilation.applyPluginsAsync (/mnt/c/Users/xxx/WebstormProjects/react-redux-starter-kit/node_modules/tapable/lib/Tapable.js:60:69)
  at Compilation.<anonymous> (/mnt/c/Users/xxx/WebstormProjects/react-redux-starter-kit/node_modules/webpack/lib/Compilation.js:563:8)

我编辑的文件是找不到的文件(main.js),但文件存在。我敢肯定还有其他人有同样的问题。有人解决了吗?

我正在使用最新的 Windows Insider Build 14965 和最新的 Ubuntu,但问题也出现在以前的版本中。

【问题讨论】:

  • 您找到解决方案了吗?
  • 找到解决方案。见下文。

标签: node.js webpack webpack-dev-server windows-subsystem-for-linux


【解决方案1】:

找到了解决方法。您必须添加:

watchOptions: {
  aggregateTimeout: 300,
  poll: 1000
}

到你的 webpack-dev-server 因为当前 WSL 不支持监听这些事件。这也适用于 Ruby 和其他人,但使用另一个配置。

here

我认为微软总有一天会解决这个问题的。

【讨论】:

  • 我使用的是 Ionic2,所以没有 webpack-dev-server。
【解决方案2】:

对于使用 Ionic 2 的我来说,上述错误是由于导入时区分大小写问题引起的。

在我的示例中,我正在执行以下操作:

import { MapRangeModel } from '../model/maprangeModel';

应该是什么时候:

import { MapRangeModel } from '../model/mapRangeModel';

【讨论】:

    猜你喜欢
    • 2017-04-08
    • 1970-01-01
    • 2017-02-11
    • 1970-01-01
    • 2018-07-03
    • 2014-01-12
    • 1970-01-01
    • 2023-03-31
    • 2021-07-10
    相关资源
    最近更新 更多