Please verify that the package.json has a valid "main" entry

Viewed 23321

Installed bootstrap via npm on my react project Importing bootstrap import 'bootstrap/dist/css/bootstrap.min.css';

but it outputs an error: Cannot find module 'D:\project\my-app\node_modules\schema-utils\src\index.js'. Please verify that the package.json has a valid "main" entry

4 Answers

Try deleting package-lock.json and run npm install

Verify that in your package.json file there is an entry for main, usually something like "main": "dist/cjs"

If you're using yarn try deleting yarn.lock and run yarn again.

Try to use "npm update --force" which resolves my issue

I went for another approach. As deleting package-lock.json & running npm install didn't work for me, I deleted my project and created another one with npx create-react-app my-react-activities.

Once the project was created, I cd into it and ran npm start.

I can't tell you why it worked, but it runs well. If anyone has an explanation for it, I would gladly read it.

Related