2016-11-08 173 views
0

我收到了幾個模塊未找到來自webpack的錯誤,但問題是文件實際上存在。我進行了三重檢查,我確定這些文件存在,但由於某種原因,webpack無法找到它們。有什麼方法可以讓我找到有關webpack失敗原因的更多信息?未找到Webpack模塊:錯誤:無法解析模塊

ERROR in ./~/react-router/BrowserRouter.js 
Module not found: Error: Cannot resolve module 'history/createBrowserHistory' in [MODULE_PROJECT_ROOT]\node_modules\react-router 
@ ./~/react-router/BrowserRouter.js 11:28-67 

ERROR in ./~/react-router/HashRouter.js 
Module not found: Error: Cannot resolve module 'history/createHashHistory' in [MODULE_PROJECT_ROOT]\node_modules\react-router 
@ ./~/react-router/HashRouter.js 11:25-61 

ERROR in ./~/react-router/HashRouter.js 
Module not found: Error: Cannot resolve module 'history/PathUtils' in [MODULE_PROJECT_ROOT]\node_modules\react-router 
@ ./~/react-router/HashRouter.js 19:17-45 

ERROR in ./~/react-router/MemoryRouter.js 
Module not found: Error: Cannot resolve module 'history/createMemoryHistory' in [MODULE_PROJECT_ROOT]\node_modules\react-router 
@ ./~/react-router/MemoryRouter.js 11:27-65 

ERROR in ./~/react-router/LocationUtils.js 
Module not found: Error: Cannot resolve module 'history/PathUtils' in [MODULE_PROJECT_ROOT]\node_modules\react-router 
@ ./~/react-router/LocationUtils.js 17:17-45 

ERROR in ./~/react-router/LocationUtils.js 
Module not found: Error: Cannot resolve module 'history/LocationUtils' in [MODULE_PROJECT_ROOT]\node_modules\react-router 
@ ./~/react-router/LocationUtils.js 8:21-53 

ERROR in ./~/react/lib/CSSPropertyOperations.js 
Module not found: Error: Cannot resolve module 'fbjs/lib/memoizeStringOnly' in [MODULE_PROJECT_ROOT]\node_modules\react\lib 
@ ./~/react/lib/CSSPropertyOperations.js 21:24-61 
+0

[Webpack babel es6給我錯誤與反應路由器1.0「模塊找不到」?](http://stackoverflow.com/questions/33979046/webpack-babel-es6-giving-me-errors- with-react-router-1-0-module-not-found) –

+0

我正在使用React Router 4.0.0-alpha.4其中[自帶歷史模塊](https://github.com/ReactTraining/react-路由器/ blob/v4/package.json),正如我上面提到的,歷史文件絕對存在。 此外,最後找不到的模塊是用於反應不反應的路由器。這讓我覺得這是webpack不響應路由器的問題。 – earthling

回答

0

我發現爲什麼webpack無法找到所需的模塊。我提供了一個到resolve.modulesDirectoriesresolveLoader.modulesDirectories的絕對路徑數組。我忘記做的是在我的數組中包含這些字段的默認值。在我的情況下,我只是將「node_modules」添加到這些文件路徑數組中,並解決了我的問題。

相關問題