1

I am doing a setup of react native on Mac, After doing everything mentioned in doc when I tried to make a sample project I got this error

node:internal/modules/cjs/loader:1042
  throw err;
  ^

Error: Cannot find module './lib/source-map-generator'
Require stack:
- /Users/macbook/.npm/_npx/7930a8670f922cdb/node_modules/metro-source-map/node_modules/source-map/source-map.js
- /Users/macbook/.npm/_npx/7930a8670f922cdb/node_modules/metro-source-map/src/composeSourceMaps.js
- /Users/macBook/.npm/_npx/7930a8670f922cdb/node_modules/metro-source-map/src/source-map.js
....
....
....

1 Answer 1

0

This StackOverflow thread accepted answer suggests removing NodeModules and then running npminstall again:

Error: Cannot find module './lib/source-map-generator'

The same accepted answer comes up in this thread: https://github.com/terinjokes/gulp-uglify/issues/174

Hope this works for you!

Sign up to request clarification or add additional context in comments.

5 Comments

this is wrong answer, just see both are different errors, I am trying to create a project so where I get this node_modules, node_modules creates after project created.
Did you clone this project off of an existing GitHub repository or build it from scratch? Either way, React automatically creates a node_modules folder that is based on the package.json file. This error probably occured because of an issue installing packages. Did you try deleting the node_modules folder and running npm install again? It will reinstall the same packages based on your package.json file. This article explains Node.js Package Manager much better than I can: digitalocean.com/community/tutorials/…
Here's another helpful article that goes into detail about why you're getting your error and how to resolve it: freecodecamp.org/news/…
there is no node_modules it happened before the files started showing, by the way I fixed it. that bug was with the npm I tried the basic create command with the --npm flag and it worked. you are sending links that have no link with this bug. and before posting the question I searched it many times.
Glad you figured out your issue. Happy coding!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.