Webpack 热重载 ENOENT 没有那个文件或目录

Webpack hot reloading ENOENT no such file or directory

我在 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 但问题也出在之前的

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

watchOptions: {
  aggregateTimeout: 300,
  poll: 1000
}

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

参见here

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

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

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

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

应该是:

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