Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 987
Hodjaev Azamat Avatar asked Feb 15 '21 12:02

Hodjaev Azamat


People also ask

What is main entry in package json?

The main field is a module ID that is the primary entry point to your program. That is, if your package is named foo, and a user installs it, and then does require("foo"), then your main module's exports object will be returned. This should be a module ID relative to the root of your package folder.

What is Package lock json?

package-lock. json is automatically generated for any operations where npm modifies either the node_modules tree, or package. json . It describes the exact tree that was generated, such that subsequent installs are able to generate identical trees, regardless of intermediate dependency updates.

Should I check in package lock json?

json intact. It is highly recommended you commit the generated package lock to source control: this will allow anyone else on your team, your deployments, your CI/continuous integration, and anyone else who runs npm install in your package source to get the exact same dependency tree that you were developing on.

How do I delete a dependency in npm?

To remove a dev dependency, you need to attach the -D or --save-dev flag to the npm uninstall, and then specify the name of the package. You must run the command in the directory (folder) where the dependency is located.


Video Answer


3 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"

like image 129
Despina Kastani Avatar answered Oct 19 '22 20:10

Despina Kastani


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

like image 25
Blessing Avatar answered Oct 19 '22 20:10

Blessing


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

like image 20
Mohamed Hussain Avatar answered Oct 19 '22 19:10

Mohamed Hussain