question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot create build: TypeError: Ajv is not a constructor

See original GitHub issue

Steps To Reproduce

  1. Update to latest react-scripts (5.0.0)
  2. Do npm run build.

The current behavior

home/node/frontend/node_modules/mini-css-extract-plugin/node_modules/schema-utils/dist/validate.js:66
const ajv = new Ajv({
            ^
TypeError: Ajv is not a constructor
    at Object.<anonymous> (/home/node/frontend/node_modules/mini-css-extract-plugin/node_modules/schema-utils/dist/validate.js:66:13)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:11[55](https://firelight.smokescreen.io/v4/frontend/-/jobs/95213#L55):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> (/home/node/frontend/node_modules/mini-css-extract-plugin/node_modules/schema-utils/dist/index.js:6:5)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:14
  • Comments:12

github_iconTop GitHub Comments

11reactions
vishnusajevcommented, Apr 28, 2022

I got this fixed after uninstalling npm-force-resolutions and removing all preinstall related to that. And then

  • rm -rf node_modules
  • rm package-lock.json
  • npm install
2reactions
pgr3931commented, Mar 30, 2022

Same issue here. Sometimes it works and sometimes it doesn’t.

Also happens on npm run start for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Ajv is not a constructor - Stack Overflow
I have this class where I try to instantiate Ajv with the new keyword and I get this error: TypeError: Ajv is not...
Read more >
TypeError: Ajv is not a constructor when I run npm run build ...
Same problem for me. I find if I delete node_modules and package-lock. json and then run npm install and npm run build ,...
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-keywords - npm
This keyword allows a string to be modified during validation. This keyword applies only to strings. If the data is not a string,...
Read more >
Fix the TypeError: MiniCssExtractPlugin is not a constructor
Solution 2. If for any reason you cannot update the package, you can use the following syntax in your webpack config file: const ......
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