Search code examples
javascriptreactjsnpmbuildajv

TypeError: Ajv is not a constructor when I run npm run build


I'm stumbling on an error every time I run npm run build

error:

/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/ts34mpr/website/client/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> (/home/ts34mpr/website/client/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)

please does anyone knows the solution or can help please! Thank you


Solution

  • Solution was to migrate from npm to yarn as following: stackoverflow.com/a/71481424/6027872