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
....
....
....
Bilal Yaqoob
  • 790
  • 1
  • 10
  • 22

1 Answers1

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!

DayByDay
  • 60
  • 6
  • 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. – Bilal Yaqoob Dec 14 '22 at 23:07
  • 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: https://www.digitalocean.com/community/tutorials/how-to-use-node-js-modules-with-npm-and-package-json – DayByDay Dec 14 '22 at 23:44
  • Here's another helpful article that goes into detail about why you're getting your error and how to resolve it: https://www.freecodecamp.org/news/error-cannot-find-module-node-npm-error-solved/ – DayByDay Dec 14 '22 at 23:55
  • 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. – Bilal Yaqoob Dec 15 '22 at 02:33
  • Glad you figured out your issue. Happy coding! – DayByDay Dec 16 '22 at 15:37