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'; 
相關問題