create-react-app
create-react-app copied to clipboard
Error when running npm start after create-react-app
I am encountering an issue when trying to start a new React app using create-react-app. After running the commands below, I get the following error when executing npm start.
npx create-react-app client
cd client
npm start
The npm start command fails with the following error message:
> [email protected] start
> react-scripts start
Cannot find module 'ajv/dist/compile/codegen'
Require stack:
- /home/tanjil/stockmaster/client/node_modules/ajv-keywords/dist/definitions/typeof.js
- /home/tanjil/stockmaster/client/node_modules/ajv-keywords/dist/keywords/typeof.js
- /home/tanjil/stockmaster/client/node_modules/ajv-keywords/dist/keywords/index.js
- /home/tanjil/stockmaster/client/node_modules/ajv-keywords/dist/index.js
- /home/tanjil/stockmaster/client/node_modules/schema-utils/dist/validate.js
- /home/tanjil/stockmaster/client/node_modules/schema-utils/dist/index.js
- /home/tanjil/stockmaster/client/node_modules/webpack-dev-server/lib/Server.js
- /home/tanjil/stockmaster/client/node_modules/react-scripts/scripts/start.js
I got this error as well, where I solved by installing 'ajv' in dev dependencies:
npm install --save-dev ajv
https://github.com/facebook/create-react-app/issues/13643#issue-2453949350
This often happens in projects created with older versions of create-react-app or when new versions of incompatible dependencies are automatically installed. I previously used the following method
- Clean up old conflicting packages.
rm -rf node_modules
rm package-lock.json
npm cache clean --force
- Manually add a compatible version of ajv (v6.x, because CRA uses that version).
npm install --save-dev ajv@6 ajv-keywords@3