JaneaSystems / nodejs-mobile

Full-fledged Node.js on Android and iOS
https://code.janeasystems.com/nodejs-mobile
Other
2.54k stars 184 forks source link

Cordova Plugin: Installing nodejs-mobile-cordova fails #219

Open BraveThrasher opened 4 years ago

BraveThrasher commented 4 years ago

Trying to add the nodejs-mobile-cordova plugin to my Cordova project fails with the following error:

Failed to install 'nodejs-mobile-cordova': CordovaError: Using "requireCordovaModule" to load non-cordova module "q" is not supported. Instead, add this module to your dependencies and use regular "require" to load it.
    at Context.requireCordovaModule (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/Context.js:57:15)
    at module.exports (/Users/thrasher/Documents/SourceCode/project1/plugins/nodejs-mobile-cordova/install/hooks/ios/before-plugin-install.js:12:19)
    at runScriptViaModuleLoader (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:181:32)
    at runScript (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:157:16)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:125:20
    at process._tickCallback (internal/process/next_tick.js:68:7)

Trying to add it with the --verbose flag gives the following output.

No scripts found for hook "before_plugin_add".
No version specified for nodejs-mobile-cordova, retrieving version from package.json
Calling plugman.fetch on plugin "nodejs-mobile-cordova@^0.3.3"
Calling plugman.install on plugin "/Users/bravethrasher/Documents/SourceCode/project1/plugins/nodejs-mobile-cordova" for platform "ios
Installing "nodejs-mobile-cordova" for ios
Running command: /Users/bravethrasher/Documents/SourceCode/project1/platforms/ios/cordova/version 
Command finished with error code 0: /Users/bravethrasher/Documents/SourceCode/project1/platforms/ios/cordova/version 
Running command: /Users/bravethrasher/Documents/SourceCode/project1/platforms/ios/cordova/version 
Command finished with error code 0: /Users/bravethrasher/Documents/SourceCode/project1/platforms/ios/cordova/version 
Finding scripts for "before_plugin_install" hook from plugin nodejs-mobile-cordova on ios platform only.
Executing script found in plugin nodejs-mobile-cordova for hook "before_plugin_install": plugins/nodejs-mobile-cordova/install/hooks/ios/before-plugin-install.js
Failed to install 'nodejs-mobile-cordova': CordovaError: Using "requireCordovaModule" to load non-cordova module "q" is not supported. Instead, add this module to your dependencies and use regular "require" to load it.
    at Context.requireCordovaModule (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/Context.js:57:15)
    at module.exports (/Users/bravethrasher/Documents/SourceCode/project1/plugins/nodejs-mobile-cordova/install/hooks/ios/before-plugin-install.js:12:19)
    at runScriptViaModuleLoader (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:181:32)
    at runScript (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:157:16)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:125:20
    at process._tickCallback (internal/process/next_tick.js:68:7)
Using "requireCordovaModule" to load non-cordova module "q" is not supported. Instead, add this module to your dependencies and use regular "require" to load it.
CordovaError: Using "requireCordovaModule" to load non-cordova module "q" is not supported. Instead, add this module to your dependencies and use regular "require" to load it.
    at Context.requireCordovaModule (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/Context.js:57:15)
    at module.exports (/Users/bravethrasher/Documents/SourceCode/project1/plugins/nodejs-mobile-cordova/install/hooks/ios/before-plugin-install.js:12:19)
    at runScriptViaModuleLoader (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:181:32)
    at runScript (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:157:16)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:125:20
    at process._tickCallback (internal/process/next_tick.js:68:7)

It seems unrelated to issue #48

jaimecbernardo commented 4 years ago

Hi @BraveThrasher ,

There's an incoming PR to fix Cordova 9 support for nodejs-mobile-cordova: https://github.com/JaneaSystems/nodejs-mobile-cordova/pull/7

The current workaround is using that branch or downgrading to Cordova 8.

Phoscur commented 4 years ago

Please also update the Getting started it still says

Cordova 7.x (Cordova 8.x is currently not supported)

BraveThrasher commented 4 years ago

Hi @jaimecbernardo I have noticed that it has been fixed in version 0.3.4

Maybe like @Phoscur mentioned you could update the Getting started like you did in README.md on GitHub

Thanks for the fix!