Skip to content

Cannot find module 'ajv/dist/compile/codegen' #13643

@lsaffre

Description

@lsaffre

Describe the bug

I am quite new to the world of npm. When I say "npx create-react-app my-app; cd my-app; npm start" as instructed on the Getting Started page, I get an error message "Cannot find module 'ajv/dist/compile/codegen'"

Did you try recovering your dependencies?

I had to manually say npm install --save-dev ajv to get it to work.

I report this as an issue because it's obviously not intended behaviour, and it's not a nice welcome to beginners. If this happens only on my machine, then I'd like to understand what's wrong with my environment.

Environment

I am using npm version 10.8.2
I did "npm install -g npm@latest" as recommended, removed the my-app directory and tried again, but the issue remains.

(dev) luc@yoga:~/work/my-app$ npm ls -g
/usr/local/lib
├── corepack@0.28.1
├── html-webpack-plugin@5.6.0
├── n@9.2.3
├── npm@10.8.2
├── react-dom@18.3.1
└── typedoc@0.25.3

Environment Info:

current version of create-react-app: 5.0.1
running from /home/luc/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app

System:
OS: Linux 6.5 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
Binaries:
Node: 20.15.1 - /usr/local/bin/node
Yarn: 1.22.22 - /usr/local/bin/yarn
npm: 10.8.2 - /usr/local/bin/npm
Browsers:
Chrome: Not Found
npmPackages:
react: ^18.3.1 => 18.3.1
react-dom: ^18.3.1 => 18.3.1
react-scripts: 5.0.1 => 5.0.1
npmGlobalPackages:
create-react-app: Not Found

Steps to reproduce

As instructed on https://create-react-app.dev/docs/getting-started :

npx create-react-app my-app
cd my-app
npm start

Expected behavior

No error message and the browser starting at http://localhost:3000

Actual behavior

(dev) luc@yoga:~/work/my-app$ npm start

> my-app@0.1.0 start
> react-scripts start

Cannot find module 'ajv/dist/compile/codegen'
Require stack:
- /home/luc/work/my-app/node_modules/ajv-keywords/dist/definitions/typeof.js
- /home/luc/work/my-app/node_modules/ajv-keywords/dist/keywords/typeof.js
- /home/luc/work/my-app/node_modules/ajv-keywords/dist/keywords/index.js
- /home/luc/work/my-app/node_modules/ajv-keywords/dist/index.js
- /home/luc/work/my-app/node_modules/schema-utils/dist/validate.js
- /home/luc/work/my-app/node_modules/schema-utils/dist/index.js
- /home/luc/work/my-app/node_modules/webpack-dev-server/lib/Server.js
- /home/luc/work/my-app/node_modules/react-scripts/scripts/start.js
(dev) luc@yoga:~/work/my-app$ 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions