webpack Module not found: Error: Can't resolve 'jquery'

≯℡__Kan透↙ 提交于 2019-11-30 20:20:10

The handlebars has nothing to do with it. The problem is that you changed resolve.modules to [path.join(__dirname, "js/helpers")]. So webpack will only look in js/helpers for any module, but jquery and other dependencies from npm are in node_modules. The default value of resolve.modules is ["node_modules"]. You also need to add node_modules to keep the regular module resolution.

resolve: {
  modules: [
    path.join(__dirname, "js/helpers"),
    "node_modules"
  ]
},

Well in my case it was something about importing jquery instead of jQuery, it is a webpack config:

externals: {
// require("jquery") is external and available
//  on the global var jQuery
"jquery": "jQuery"

}

have a look at this: webpack Can't resolve 'jquery'

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!