I am getting error while building phonegap android app on my linux (ubuntu 12.04) machine.
I have installed nodejs, set JAVA_HOME, ANT_HOME, ANDROID_HOME vars and $JAVA_HOME/bin, $ANT_HOME/bin, $ANDROID_HOME/tools, $ANDROID_HOME/platform-tools to the path. when I am running command phonegap local build android
, I am getting following error:
ME@My-PC:/dos/PhoneGap/HelloWorld$ phonegap local run android
[phonegap] compiling Android...
[error] An error occurred while building the android project.
module.js:340
throw err;
^
Error: Cannot find module 'shelljs'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/dos/PhoneGap/HelloWorld/platforms/android/cordova/lib/build.js:22:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
Thanks for Helping
you must
$cordova platform remove android
$cordova platform add android
because there is directory is missing in
platforms/android/cordova/node_modules/shelljs
or you can create another app and copy the missing file and add it in your app
Recently solution
in terminal go to your app then
cd platforms/android/cordova
sudo npm install shelljs
it's working fine with me
I already installed shelljs:
sudo npm install shelljs -g
But I needed to set NODE_PATH
export NODE_PATH=/usr/local/lib/node_modules
Not sure why it was missing...
I have needed to update cordova-android engine (from 3.5.1) to 3.6.0 (because required by the splashscreen plugin, here)
To build the Android project (and evict the above errors), i have added in the package.json
file (of my Cordova project root folder), the following npm dependencies:
"dependencies": {
"q": "^1.2.0",
"shelljs": "^0.4.0",
"which": "^1.0.9"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With