Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm install error on ''Cordova: Use Native Modules' #11

Open
SamiNodejs opened this issue Nov 13, 2018 · 3 comments
Open

npm install error on ''Cordova: Use Native Modules' #11

SamiNodejs opened this issue Nov 13, 2018 · 3 comments

Comments

@SamiNodejs
Copy link

Hi,
Please how to install a new npm module using the version ''Cordova: Use Native Modules''.
It works on ''Native Gradle Sample using a Node Project folder '' but with ''Cordova: Use Native Modules'' I get the error message ''Unsupported opperating system for nodejs-mobile native builds: Windows 7''.
thank you for you help.

@jaimecbernardo
Copy link
Member

Hi @SamiNodejs ,
That's because native module cross building is not supported on Windows. Here's a disclaimer in the sample: https://github.com/janeasystems/nodejs-mobile-samples/tree/1eb9c4c0f1e02b009ca55bc610cc9e8cda403afa/cordova/UseNativeModules#cordova-use-native-modules-sample

Disclaimer: Building native modules is only available on macOS and Linux at the time of writing this sample.

The same information can be found in the plugin's README.md : https://github.com/janeasystems/nodejs-mobile-cordova/tree/be459ac4702a825a9254be03fc9448a5487436db#native-modules

@SamiNodejs
Copy link
Author

Thank you very much for taking the time to answer.
Sorry, inadvertently, I didn't read that disclaimer.
After installing Nodejs modules in Linux could we import the project to Android studio in windows?
I’ve tried to build the project ‘’Cordova Use Native Modules Sample’’ on ubuntu (18.04) but I still receive the error message below.
Sorry for newbie question, is this related to Cordova version? How could we install the old version of Cordova (ver7.)? I tried to uninstall Cordova 8 using: sudo npm uninstall -g cordova , but I still receive :
cordova –version -> 8.1.2 ([email protected]) !
How should we install sqlite3 and sha3 modules in order to build cordova examples?

This is part of the received message when building ’’Cordova Use Native Modules Sample’’ using Android studio:
Cause: error=2, No such file or directory
org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':BuildNpmModulesarmeabi-v7a'.
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:145)
at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:115)
at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:78)
... 3 more
Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'npm'
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27)
at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36)
at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:67)
... 4 more
Caused by: java.io.IOException: Cannot run program "npm" (in directory "/home/sami/cordovatest2/nodejs-mobile-samples/cordova/UseNativeModules/platforms/android/build/nodejs-native-assets-temp-build/nodejs-native-assets-armeabi-v7a/nodejs-project"): error=2, No such file or directory
at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25)
... 6 more
Caused by: java.io.IOException: error=2, No such file or directory

@jaimecbernardo
Copy link
Member

Hi,

After installing Nodejs modules in Linux could we import the project to Android studio in windows?

The native-assets folders created for the final APK could manually be added to the application assets and be picked up at runtime. This could work. Give it a try and let us know if it works.

Sorry for newbie question, is this related to Cordova version? How could we install the old version of Cordova (ver7.)?

Starting from the sample instructions, it will install the cordova-android 6.4.0, which is the cordova-android for cordova 7.0, so it should be fine. cordova platforms add [email protected] would be the way to use the proper platform version for newer cordova versions.

Could not start 'npm'
Cannot run program "npm"
Caused by: java.io.IOException: error=2, No such file or directory

It looks like npm is not accessible through the command line on your development machine. That's why you are getting that error. 'node' and 'npm' are requisites for building native modules, since the process essentially calls npm rebuild with the right environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants