1

我在Windows上使用Ubuntu。我克隆了一个新的react-redux-starter-kitreact-redux-universal-hot-example和我自己的实现有相同的问题。Webpack热重载ENOENT没有这样的文件或目录

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),但该文件存在文件。我相信还有其他人也有同样的问题。有没有人有修复?

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

+0

你找到一个解决办法? – Richard

+0

找到解决办法。见下。 – Piu130

回答

1

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

watchOptions: { 
    aggregateTimeout: 300, 
    poll: 1000 
} 

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

请参阅here

我想微软会在某一天解决这个问题。

+0

我使用Ionic2,所以没有webpack-dev-server。 – Richard

0

对于使用Ionic 2的用户,上述错误是由于导入时出现了大小写敏感问题导致的。

在我的例子,我在做以下几点:

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

当它应该有这么好了:

import { MapRangeModel } from '../model/mapRangeModel'; 
相关问题