facebook / create-react-app

Set up a modern web app by running one command.
https://create-react-app.dev
MIT License
102.77k stars 26.87k forks source link

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

Open lsaffre opened 3 months ago

lsaffre commented 3 months ago

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$ 
zinebelouarradi commented 3 months ago

Run npm uninstall -g create-react-app to remove the global create-react-app package. Then, try using npx create-react-app my-app again.

npx will automatically download the latest version of create-react-app and use it to set up your project.

lsaffre commented 3 months ago

Run npm uninstall -g create-react-app to remove the global create-react-app package. Then, try using npx create-react-app my-app again.

npx will automatically download the latest version of create-react-app and use it to set up your project.

Thanks for your suggestion. Unfortunately it didn't help. Your suggestion gave me the idea to try "sudo apt remove npm" followed by "sudo apt install npm". But this too didn't help.

MosheHM commented 5 days ago

this problem happens to me also and i just migrate my app to the now version