TypeError: Ajv is not a constructor

See original GitHub issue

Bug report

we recently updated our angular poject to v13.x.x now when i running ng serve i get an error:

Actual Behavior

[error] TypeError: Ajv is not a constructor
    at Object.<anonymous> (./node_modules/mini-css-extract-plugin/node_modules/schema-utils/dist/validate.js:66:13)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (./node_modules/mini-css-extract-plugin/node_modules/schema-utils/dist/index.js:6:5)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (./node_modules/mini-css-extract-plugin/dist/index.js:8:20)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)

in the validate.js line 21 it says require(“ajv”).default which is undefined - only require(“ajv”) returns the correct object

Expected Behavior

How Do We Reproduce?

Please paste the results of npx webpack-cli info --aditional-package schema-utils here, and mention other relevant information

PS: ^-- there is a ‘d’ missing in the header

System: OS: Linux 5.4 Ubuntu 20.04.2 LTS (Focal Fossa) CPU: (16) x64 AMD Ryzen 9 5950X 16-Core Processor Memory: 3.05 GB / 17.58 GB Binaries: Node: 16.13.1 - /usr/bin/node npm: 8.3.0 - /usr/local/bin/npm Browsers: Firefox: 95.0.1 Packages: babel-loader: ^8.2.3 => 8.2.3 compression-webpack-plugin: ^8.0.1 => 8.0.1 ts-loader: ^9.2.6 => 9.2.6 webpack: ^5.65.0 => 5.65.0 worker-loader: ^3.0.8 => 3.0.8

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jonnytest1commented, Jan 27, 2022

also check wether that version is still the latest one of its package just in case

1reaction
shye0000commented, Jan 27, 2022

@alexander-akait yeah, I think so too and I’d love to submit an issue to them, but I’m not sure how to explain this accurately.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Ajv is not a constructor - Stack Overflow
What's causing this is that ajv uses export default or export = syntax, and you're using import * as which imports an object...
Read more >
Cannot create build: TypeError: Ajv is not a constructor #12155
I found a very hacky workaround: replace instances of require(<<SOME MODULE NAME>>) that cause issues in library code with relative requires, ...
Read more >
TypeError: Ajv is not a constructor when I run npm run build ...
Coding example for the question TypeError: Ajv is not a constructor when I run npm run build-Reactjs.
Read more >
TypeError: "x" is not a constructor - JavaScript - MDN Web Docs
The JavaScript exception "is not a constructor" occurs when there was an attempt to use an object or a variable as a constructor,...
Read more >
ajv-validator/ajv - Gitter
Hello, I wanted to ask why AJV is relying on dynamic functions for validation. ... Hi @epoberezkin - when adding .default I get...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found