middy: validator: Module not found 'avj-keywords'
When using serverless with serverless-bundle.
Warning
If you use serverless with serverless-bundle you will run into a build issue (Module not found ‘ajv-keywords’) with the default configuration. See #560 for details. You can use v1.2.0 or set ajvPlugins to {} to remove all plugins and work around this issue.
https://github.com/middyjs/middy/pull/552#issuecomment-684126761
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (6 by maintainers)
I maybe having the same issues as @ThomasKiec here. Setup = monorepo, typescript, serverless.
When using validator version 1.4.0 with webpack 4 and serverless-webpack I was getting a whole bunch of WARNINGS, but it still bundled and worked. An example warning: WARNING in …/…/node_modules/ajv-errors/README.md 1:0 Module parse failed: Unexpected character ‘#’ (1:0)
Then I tried to upgrade from webpack 4 to webpack 5 and am now getting ERROR in …/…/node_modules/ajv-errors/LICENSE 1:4 Module parse failed: Unexpected token (1:4) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
But as it is an error it won’t bundle.
I seem to have gotten around this for now with the following ignore loader regex, though it is hacky
{ test: /(?=(ajv-.*))((?=.*(\.(?!(js|json)\b).*))|(?=.*(LICENSE)))/, loader: 'ignore-loader' },1 thing I did notice was that if you update following it works … (well it did for me and makes no sense why)
const pckJson = require(…/…/ajv-${p}/package.json) pluginsInstances[p] = require(…/…/ajv-${p}/${pckJson.main})to:
const pckJson = require(…/…/ajv-${p}/package.json); const mainFile =…/…/ajv-${p}/${pckJson.main}; pluginsInstances[p] = require(mainFile);But I cannot change the node_module on my CI server.
Hopefully this will help someone else 😃
Going to re-open for now to ensure this is well tested in the next version. I may reach out for help testing.
Great, updated our project and everything back to work like a charm 😃
v1.3.2 has the fix in it. cc @renanwilliam