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

7

13

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

Module answered 15/2, 2021 at 12:5 Comment(0)
S
18

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"

Sumter answered 15/2, 2021 at 12:37 Comment(1)
and if no main present, how to create a proper one?Fume
C
5

I had to delete both my package-lock.json and node_modules, then run npm i. (this was in my react app)

Councillor answered 5/10, 2022 at 15:20 Comment(0)
P
2

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

Piscatorial answered 17/5, 2022 at 10:23 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Decrescendo
L
1

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

Licht answered 22/7, 2021 at 8:56 Comment(0)
S
1

This happened to me on our Jenkins server. The solution was to run the job once with yarn cache clean. After the job completed we removed that line and everything was happy again.

Shabbygenteel answered 17/4, 2023 at 12:54 Comment(0)
Z
0

Running npm ci may be a faster solution.

Zoarah answered 12/4, 2024 at 11:2 Comment(0)
B
-1

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.

Bouie answered 14/11, 2021 at 12:17 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.