Gcpt
Gcpt

Reputation: 51

Cordova cannot find module

I allready searched for solutions but couldn't find anything that works.

I'm trying to build / run apk with cordova but the emulator (and also my phone) won't start the app and fail on installation. I tried to re-create the projet and re-install cordova but have this issue :

Error: Cannot find module 'C:\Users\...\AppData\Roaming\npm\node_modules\cordova\bin\cordova'

I also tried to do :

npm cache clean

Nothing is working, can someone help me please ? Thank you !

Upvotes: 1

Views: 21663

Answers (6)

Cahyanudien AS
Cahyanudien AS

Reputation: 27

ss image

i tried :

npm uninstall -g cordova  

npm install -g cordova@latest

but, everytime i run cordova

module.js:471
throw err;
^ Error: Cannot find module 'C:\Users\MYUSERNAME\AppData\Roaming\npm\node_modules\cordova\bin\cordova'

im install manualy, open : C:\Users\MYUSERNAME\AppData\Roaming\npm\node_modules\ and create folder : cordova\bin

then i run

yarn add cordova

this solve, my problem

Upvotes: 0

Stredsto
Stredsto

Reputation: 331

You just need to run these commands

npm uninstall -g cordova
npm install -g cordova@latest

Above commands are already answered but removing android and adding it again is important and then these :

cordova platform rm android/ios/browser
cordova platform add android/ios/browser

Worked for me, hope it help others.

Upvotes: 1

In my case solved by removing and adding platform android again

cordova platform rm android
cordova platform add android

Upvotes: 5

core114
core114

Reputation: 5325

Follow these Steps:

npm uninstall -g cordova
npm install -g cordova@latest

Upvotes: 0

Kevin Hernandez
Kevin Hernandez

Reputation: 25

I know, this question is kinda old but I got the same problem and I "by-pass" it with this method.

(SOLVED) Error: Cannot find module 'C:...\node_modules\cordova\bin\cordova' #3301

Actually, using ionic (Ionic CLI) : 3.20.0

first of all, check the JRE installation on your computer, if is ok, follow this steps

  1. ionic serve
  2. cordova clean android (or IOS)
  3. rm -rf node_modules (just delete node_modules folder)
  4. npm install
  5. cordova build android (without ionic)

It will add plugins to your project and also will compile it to an APK.

EDIT:

Just create another project, copy the "src" folder to the new one and ready to go!

Upvotes: 2

Qin Chao
Qin Chao

Reputation: 178

I encountered the similar situation, here is the error information:

module.js:471
    throw err;
    ^

Error: Cannot find module 'C:\Users\MYUSERNAME\AppData\Roaming\npm\node_modules\cordova\bin\cordova'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3

It happened after I upgraded my cordova with the command:

npm install cordova -g

Even when I ran the "cordova" command solely, same error I could get.

Finally solved by reinstall the cordova completely :

npm uninstall cordova -g

then

npm install cordova -g

Upvotes: 8

Related Questions