简体   繁体   English

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

[英]Webpack Module not found: Error: Cannot resolve module

I am getting a few module not found errors from webpack, but the problem is the files are actually there. 我从webpack中收到一些模块未找到的错误,但问题是文件实际上在那里。 I've triple-checked and I am sure the files are there, but for some reason, webpack is failing to find them. 我已进行了三重检查,并确定文件在那里,但是由于某些原因,webpack无法找到它们。 Is there any way for me to find out more information on why webpack is failing? 我有什么办法找出有关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

I've found out why webpack was unable to find the requested modules. 我发现了为什么webpack找不到所需的模块。 I had provided an array of absolute paths to resolve.modulesDirectories and resolveLoader.modulesDirectories . 我已经提供的,以绝对路径的数组resolve.modulesDirectoriesresolveLoader.modulesDirectories What I had forgotten to do was including the default value for these fields in my arrays. 我忘记要做的是在数组中包括这些字段的默认值。 In my case, I just prepended "node_modules" to these arrays of file paths and that solved my problem. 就我而言,我只是将“ node_modules”放在文件路径的这些数组中,这解决了我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM