csf
csf

Reputation: 1011

Phonegap error: Cannot find module

I'm trying to create a HelloWorld project but are experiencing an error

phonegap create C:\Desenv\PhoneGap\learn com.cassia.hello HelloWorld

Error:

C:\Users\cassiasantos>phonegap create teste com.cassia.hello HelloWord
module.js:338
    throw err;
          ^
Error: Cannot find module '..\..\node_modules\cordova\node_modules\cordova-lib'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (C:\Users\cassiasantos\AppData\Roaming\npm\node_module
s\phonegap\lib\cordova\index.js:16:26)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)

Upvotes: 6

Views: 10616

Answers (3)

Mohammed Azhar
Mohammed Azhar

Reputation: 259

I had the same issue as yours. I just uninstalled and reinstalled NodeJS and that worked for me.

To uninstall NodeJS on Windows, goto Control Panel->Programs and Features. In the list of installed software, you will find NodeJS. Right click on NodeJS and uninstall it.

To reinstall NodeJS, visit their website. click here to visit their website and download the latest LTS version of NodeJS.

After doing this, check if you again have the same error. If you do, then run the command:

npm install -g phonegap

That should definitely fix your issue! Cheers!

Upvotes: 0

hjpithadia
hjpithadia

Reputation: 216

It seems that you have to install all the modules - at least this fix worked for me.

Use

sudo npm update -g

Found the solution in an ionic forum.

Upvotes: 2

Phipe Teoh
Phipe Teoh

Reputation: 41

this is phonegap bugs. Here is temporary solution

Install cordova-lib under
../node_modules/phonegap/node_modules/cordova

Goto ../node_modules/phonegap/node_modules/cordova

Exec npm install cordova-lib

Upvotes: 3

Related Questions