Open justinbachtell opened 5 months ago
I'm having the same issue too.
I'm also having this issue with every version of @wordpress/scripts back to 27.0.0.
Others seem to fix this by adding ajv@latest to their dev dependencies but that's not ideal.
I had the same issue with a .npmrc
file which set legacy-peer-deps = true
and/or prefer-dedupe = true
.
Description
When running
npm run dev
ornpm run build
in my repo, I am getting the following error:[0] [webpack-cli] Failed to load 'C:\Users\user\repository\node_modules\@wordpress\scripts\config\webpack.config.js' config [0] [webpack-cli] Error: Cannot find module 'ajv/dist/compile/codegen'
If I run
npm install ajv
the issue is fixed, but there seems to be an issue with the ajv dependency within @wordpress/scripts, which I would prefer to resolve over installing the package as a package.json dependency.Step-by-step reproduction instructions
When running
npm run dev
ornpm run build
an error is thrown:Update @wordpress/scripts using
npm install @wordpress/scripts@latest
.Run
npm run dev
ornpm run build
and the same error is thrown.Delete /node_modules and package-lock.json, and then run
npm install
.Run
npm run dev
ornpm run build
and the same error is thrown.Screenshots, screen recording, code snippet
$npm run dev
repository@1.0.0 dev concurrently "wp-scripts start --webpack-copy-php" "grunt watch --force" "npm run sass-watch"`
[1] Running "watch" task [1] Waiting... [2] [2] > repository@1.0.0 sass-watch [2] > sass -w --style=compressed src/styles:public/min/css/ [2] [0] [webpack-cli] Failed to load 'C:\Users\user\repository\node_modules\@wordpress\scripts\config\webpack.config.js' config [0] [webpack-cli] Error: Cannot find module 'ajv/dist/compile/codegen' [0] Require stack: [0] - C:\Users\user\repository\node_modules\ajv-keywords\dist\definitions\typeof.js [0] - C:\Users\user\repository\node_modules\ajv-keywords\dist\keywords\typeof.js [0] - C:\Users\user\repository\node_modules\ajv-keywords\dist\keywords\index.js [0] - C:\Users\user\repository\node_modules\ajv-keywords\dist\index.js [0] - C:\Users\user\repository\node_modules\schema-utils\dist\validate.js [0] - C:\Users\user\repository\node_modules\schema-utils\dist\index.js [0] - C:\Users\user\repository\node_modules\copy-webpack-plugin\dist\index.js [0] - C:\Users\user\repository\node_modules\@wordpress\scripts\config\webpack.config.js [0] - C:\Users\user\repository\node_modules\webpack-cli\lib\webpack-cli.js [0] - C:\Users\user\repository\node_modules\webpack-cli\lib\bootstrap.js [0] - C:\Users\user\repository\node_modules\webpack-cli\bin\cli.js (C:\Users\user\repository\node_modules\ajv-keywords\dist\definitions\typeof.js:3:19)
[0] at Module._compile (node:internal/modules/cjs/loader:1159:14)
[0] at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
[0] at Module.load (node:internal/modules/cjs/loader:1037:32)
[0] at Module._load (node:internal/modules/cjs/loader:878:12)
[0] at Module.require (node:internal/modules/cjs/loader:1061:19) {
[0] code: 'MODULE_NOT_FOUND',
[0] requireStack: [
[0] 'C:\Users\user\repository\node_modules\ajv-keywords\dist\definitions\typeof.js',
[0] 'C:\Users\user\repository\node_modules\ajv-keywords\dist\keywords\typeof.js',
[0] 'C:\Users\user\repository\node_modules\ajv-keywords\dist\keywords\index.js',
[0] 'C:\Users\user\repository\node_modules\ajv-keywords\dist\index.js',
[0] 'C:\Users\user\repository\node_modules\schema-utils\dist\validate.js',
[0] 'C:\Users\user\repository\node_modules\schema-utils\dist\index.js',
[0] 'C:\Users\user\repository\node_modules\copy-webpack-plugin\dist\index.js',
[0] 'C:\Users\user\repository\node_modules\@wordpress\scripts\config\webpack.config.js',
[0] 'C:\Users\user\repository\node_modules\webpack-cli\lib\webpack-cli.js',
[0] 'C:\Users\user\repository\node_modules\webpack-cli\lib\bootstrap.js',
[0] 'C:\Users\user\repository\node_modules\webpack-cli\bin\cli.js',
[0] 'C:\Users\user\repository\node_modules\webpack\bin\webpack.js'
[0] ]
[0] }
[0] wp-scripts start --webpack-copy-php exited with code 2
[2] [2024-06-24 11:23] Compiled src\styles\global-editor.scss to public\min\css\global-editor.css.
[2] [2024-06-24 11:23] Compiled src\styles\global-utility-classes.scss to public\min\css\global-utility-classes.css.
[2] [2024-06-24 11:23] Compiled src\styles\globals.scss to public\min\css\globals.css.
[2] Sass is watching for changes. Press Ctrl-C to stop.
[0] - C:\Users\user\repository\node_modules\webpack\bin\webpack.js
[0] at Module._resolveFilename (node:internal/modules/cjs/loader:995:15) [0] at Module._load (node:internal/modules/cjs/loader:841:27) [0] at Module.require (node:internal/modules/cjs/loader:1061:19) [0] at require (node:internal/modules/cjs/helpers:103:18) [0] at Object.
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes