How to fix error "Cannot find module" using "expo start" - react-native

After upgrading expo-cli to the latest version. I tried starting my app with 'expo start' but I got this error
C:\Users\DevLewa\Desktop\app\AgroSprite>expo
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'split-string'
at Function.Module._resolveFilename
(internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous>
(C:\Users\DevLewa\AppData\Roaming\npm\node_modules\exp
o-cli\node_modules\braces\lib\utils.js:3:19)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
How do I fix this please?

rollback to version 2.4.3
npm install -g expo-cli#2.4.3

I installed the missing module using
npm install -g split-string
and it worked.

I faced the same problem . I uninstalled expo-cli and nodejs and installed again. It works for me.

Related

Not able to run any npm command due to following error - Error: Cannot find module 'semver'

previously node was working properly.
After that as i wanted to install express & socket.io.
it asked for node version update.
i tried to update node version & i believe i forgot some command to run in updation process.
now it's giving following error on any npm command. even if i type only npm, that'll give error.
m#m-Lenovo-ideapad-320-15IKB:/var/www/html/chat$ npm -v
nternal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'semver'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/usr/share/npm/lib/utils/unsupported.js:2:14)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Finally it got solved, i think following process worked.
deleted npm module from usr folder
I removed npm module
cleared the cache
installed npm
& it worked
The mistake i was doing was not clearing the cache

Problem when using generator-rn-toolbox to apply icon

I use generator-rn-toolbox to set icon and splash screen for my react-native app as instructions
- install generator npm install -g yo generator-rn-toolbox
- install brew brew install imagemagick
- generate icons yo rn-toolbox:assets --icon ~/Desktop/logo.png
Then I encountered an error as below
internal/modules/cjs/loader.js:584
throw err;
^
Error: Cannot find module 'universal-analytics'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/usr/local/lib/node_modules/generator-rn-toolbox/analytics.js:1:74)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/usr/local/lib/node_modules/generator-rn-toolbox/generators/assets/index.js:5:19)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
I tried to run npm install universal-analytics but it doesn't work. Do you have any solutions?
I solved by
npm remove -g yo generator-rn-toolbox
npm install -g yo generator-rn-toolbox
We look forward to helping you

Why can I not start the Vue UI after installing the Vue CLI?

Using the following:
node 8.11.2
npm 6.3.0
I then try to install the Vue CLI (#vue/cli#3.0.0):
npm i -g #vue/cli
but when I run the following command:
vue ui
I get the following error:
Error: Cannot find module 'core-js/modules/es7.object.entries'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Apps\caches\npm\node_modules\#vue\cli\node_modules\apollo-upload-server\lib\mi
ddleware.js:14:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
It turned out I had to install the core-js package explicitly.
npm i -g core-js
Not sure why this wasn't installed as a dependency though.
The issue has been reported HERE and has been fixed in v3.0.1.

npm command : Cannot find module 'buffer-shims'

I am using MacOS High Sierra(10.13.5).
When I run npm command, e.g. npm -v, I constantly get this error:
module.js:471
throw err;
^
Error: Cannot find module 'buffer-shims'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_readable.js:36:18)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
I tried the following solution, which I found after googling:
rm -r node_modules; rm package-lock.json; npm install
I succeeded at removing the node_modules folder, but I can't find a package-lock.json file and I still get the same error.
How do I resolve the npm error I am encountering?
No idea if this is still necessary, but for future reference: I encountered the same problem and was able to fix it.
What I did was just reinstall nodejs (11.1.0 at the time of writing) and then all npm commands were working again. I think for some odd reason the nodejs/npm install got fubar and kept on throwing the aforementioned errors.

Cannot find module './packager/babelRegisterOnly'

This error probably has to do with package manager and happens when I run react-native start
Full Error:
module.js:340
throw err;
^
Error: Cannot find module './packager/babelRegisterOnly'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:289:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/Users/amirsharif/mobile-rappad/node_modules/react-native/cli.js:11:1)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
I uninstalled react native with NPM then ran npm install react-native again and it worked. I cleared out everything in the node_modules folder.
Uninstall react-native fitst, then re-install it. It's work to me.