找不到Webpack模块:错误:无法解析模块

时间:2016-11-08 22:57:19

标签: javascript node.js 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

1 个答案:

答案 0 :(得分:0)

我发现为什么webpack无法找到所需的模块。我提供了一系列绝对路径resolve.modulesDirectoriesresolveLoader.modulesDirectories。我忘记做的是在我的数组中包含这些字段的默认值。就我而言,我只是将“node_modules”添加到这些文件路径数组中,这解决了我的问题。