jquery-validation-unobtrusive: Webpack build with version 3.2.8 is failing
When using the latest version from NPM (3.2.8) with webpack, the following error occurres:
ERROR in ./node_modules/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.js
Module not found: Error: Can't resolve 'jquery.validate' in '[path]\node_modules\jquery-validation-unobtrusive\dist'
@ ./node_modules/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.js 11:8-75
@ multi bootstrap jquery jquery-validation jquery-validation-unobtrusive popper.js
I think webpack tries to resolve jquery.validate as a dependency (via AMD define) but it fails because it’s probably known within webpack as jquery-validation. A workaround is to add the following rule to the webpack config:
module: {
rules: [
{
parser: {
amd: false,
}
},
...other rules...
]
}
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 19 (7 by maintainers)
Commits related to this issue
- [Fixes #79] Webpack build with version 3.2.8 is failing — committed to aspnet/jquery-validation-unobtrusive by kichalla 6 years ago
- Actually fix issue #79: Webpack build with version 3.2.8 is failing - Added webpack as part of build to catch any errors when doing a build — committed to aspnet/jquery-validation-unobtrusive by kichalla 6 years ago
- Added Webpack as part of build process to catch issues like in https://github.com/aspnet/jquery-validation-unobtrusive/issues/79 — committed to aspnet/jquery-validation-unobtrusive by kichalla 6 years ago
- fix: change jquery.validation to jquery-validation Fixes #79 — committed to ruant/jquery-validation-unobtrusive by ruant 6 years ago
- Added Webpack as part of build process to catch issues like in https://github.com/aspnet/jquery-validation-unobtrusive/issues/79 — committed to aspnet/jquery-validation-unobtrusive by kichalla 6 years ago
- Added Webpack as part of build process to catch issues like in https://github.com/aspnet/jquery-validation-unobtrusive/issues/79 — committed to aspnet/jquery-validation-unobtrusive by kichalla 6 years ago
- Added Webpack as part of build process to catch issues like in https://github.com/aspnet/jquery-validation-unobtrusive/issues/79 — committed to aspnet/jquery-validation-unobtrusive by kichalla 6 years ago
- Added Webpack as part of build process to catch issues like in https://github.com/aspnet/jquery-validation-unobtrusive/issues/79 — committed to aspnet/jquery-validation-unobtrusive by kichalla 6 years ago
- Added Webpack as part of build process to catch issues like in https://github.com/aspnet/jquery-validation-unobtrusive/issues/79 — committed to aspnet/jquery-validation-unobtrusive by kichalla 6 years ago
- Added Webpack as part of build process to catch issues like in https://github.com/aspnet/jquery-validation-unobtrusive/issues/79 — committed to aspnet/jquery-validation-unobtrusive by kichalla 6 years ago
- [Fixes #79] Webpack build with version 3.2.8 is failing — committed to aspnet/jquery-validation-unobtrusive by kichalla 6 years ago
For people using webpack, the easiest option is to alias
jquery.validate
in the resolve block of webpack. Below tested with Webpack 4 (latest) and latest versions of both jquery-validation and jquery-validation-unobtrusive. This way there is no need to hack thejquery-validation-unobtrusive
package files, and when the offending lines are fixed in a next release your webpack build will keep working.Since CI/CD is not implemented, when will this fix be pushed to npm?
@kichalla This is not fixed. You changed it from
jquery.validate
tojquery.validation
. It needs to bejquery-validation
.Just FYI, a new version (3.2.10) having the correct fix for this has been published to npm registry few minutes ago.
Same here, downgrading to 3.2.6 works again. For those unfamiliar with semver: remove the ^ from package.json before 3.2.6 or it will force an update to 3.2.8 since it’s a patchversion.
EDIT: Only read half the issue, as is tradition on the interwebs. Disabling AMD also works if you want to update.
The problem is that
jquery unobtrusive
is trying to load module with name jquery.validate. But such module is not valid because in latest version ofjquery-validation
export was defined as jquery Check it here. https://cdn.jsdelivr.net/npm/jquery-validation@1.17.0/dist/jquery.validate.jsI think this is bug in
jquery-validation
itself because docs says that you need to require dependency jquery.validate but not jquery.So the quick fix would just replacing jquery.validate to jquery in
jquery-validation-unobtrusive
library or jquery to jquery.validate injquery-validation
library.