I have built a custom NodeJS module in C++, and I would like to use that in my electron app.
The module compilation using node-gyp works fine, and it copies the files in a dedicated directory. I can also install it by referring to the folder in my package.json file.
However, when I run the application, I get the following error:
(node:20800) UnhandledPromiseRejectionWarning: Error: The module '\?\D:\GitProjects\addon-test\local_node_modules\zeelicensenode\zeelicensenodejsaddon.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 93. This version of Node.js requires
NODE_MODULE_VERSION 103. Please try re-compiling or re-installing
The module is compiled on the same Windows machine I am running the application and has only one NodeJS version installed.
D:\GitProjects\addon-test> node --version
v16.13.2
As per the electron documentation, it uses a different ABI than the native NodeJS binary, so they suggest to build the module in a different way. Following that documentation, I updated the make.ps1 file of C++ module as follows:
make.ps1
$env:Path="$($env:APPDATA)\npm;$($env:Path)"
npm install -g node-gyp
node-gyp clean
node-gyp configure
$env:HOME="$($env:USERPROFILE)\.electron-gyp;$($env:HOME)"
node-gyp build --target=18.1.0 --arch=x64 --dist-url=https://atom.io/download/electron
copy -Verbose .\build\Release\zeelicensenodejsaddon.node .\dist
In my electron application, I have the following dependencies:
package.json
"dependencies": {
"#quasar/extras": "^1.0.0",
"core-js": "^3.6.5",
"quasar": "^2.0.0",
"vue": "^3.0.0",
"vue-router": "^4.0.0",
"zeelicensenodejs": "file:local_node_modules/zeelicensenode"
},
"devDependencies": {
"#quasar/app": "^3.0.0",
"electron": "^18.1.0",
"electron-rebuild": "^3.2.7"
}
The local_node_modules/zeelicensenode folder contains the declaration file, package.json file, zeelicensenodejsaddon.node file and a JS file that exports the module. The JS file has these lines:
const license = require('./zeelicensenodejsaddon');
module.exports = license;
NODE_MODULE_VERSION 103 refers to the current NodeJS version (18.x), but I do not understand where it is coming from. I have NodeJS 16.x installed on my machine, and as per the Electron's release information, Electron v18.1.0 also has NodeJS 16.x.
Is there anything I am missing to make this custom module work with Electron?
Related
I have a react project in which I would like to use this native node.js addon, which is a wrapper for a C++ SDK.
I've successfully used this module in the past within an Electron project, and can run the sample successfully with node as well.
My question is how I would be able to use this in React, or write my own React friendly solution using the C++ SDK.
I've tried to clone the module and place it under a lib folder in my react project, I ran npm install within that folder to install it's dependencies and tried to run the included example directly with node. This went fine. But using the sample directly from within my React app fails with the following error code ts3client.on is not a function.
So it passes the line were the library is required with var ts3client = require('../../lib/node-ts3sdk-client/api.js'); but that's the furthest I managed to get. I could play around a little bit more, but would like to get some opinions on what might be the best approach here.
Edit
As requested I have added a small example to reproduce the issue I am facing.
Create a simple react app
npm init react-app so-node-addon-react
Clone this repository under src/lib/
git clone https://github.com/svenpaulsen/node-ts3sdk-client.git
Install the module's dependencies
cd node-ts3sdk-client
npm install
Expose some part of the client example by wrapping the try-catch block starting from line 160 in an exported function like so
export function connect() {
try { ... }
catch { ... }
}
Call the function from your project's App.tsx
import { connect } from './lib/node-ts3sdk-client/examples/client_minimal'
...
connect()
Run the project
npm start
This should result in the following error: ts3client.on is not a function
My Expo project requires the latest version of react-native-svg library to render my SVGs correctly. Currently it's version 9.3.5
From package-json.lock, I see that my current Expo SDK 32 has version 8.0.10 listed.
"dependencies": {
"react-native-svg": {
"version": "8.0.10",
"resolved": "https://registry.npmjs.org/react-native-svg/-/react-native-svg-8.0.10.tgz",
"integrity": "sha512-gsG5GUdvlox67+ohLnq3tZSqiYBmz4M5lKKeUfnJZ8EPrMMS5ZgaVj7Zcccee1VvINS5xQaoenUJdha/GEo34w==",
"requires": {
"color": "^2.0.1",
"lodash": "^4.16.6",
"pegjs": "^0.10.0"
}
}
}
I have tried just installing latest react-native-svg alongside Expo by using
npm install react-native-svg#9.3.5
However, when running the app I get an error:
Tried to register two views with the same name RNSVGRect
So how can I force Expo to use the latest version? I don't see any react-native-svg dependencies anywhere and changing the package-lock.json directly doesn't seem like a good idea.
Short answer to my question is: you can't. At least not without some ugly hacks that are more trouble than they're worth.
The good news is that SDK 33 now comes with "react-native-svg": "~9.4.0" as a dependency and this is almost the latest version as of this writing.
I unsuccessfully trying to build boost under osx
What I tried
git checkout boost-1.59.0
./bootstrap.sh
Building Boost.Build engine with toolset darwin... tools/build/src/engine/bin.macosxx86_64/b2
Detecting Python version... 2.7
Detecting Python root... /System/Library/Frameworks/Python.framework/Versions/2.7
Unicode/ICU support for Boost.Regex?... not found.
Generating Boost.Build configuration in project-config.jam...
Bootstrapping is done. To build, run:
./b2
To adjust configuration, edit 'project-config.jam'.
Further information:
- Command line help:
./b2 --help
- Getting started guide:
http://www.boost.org/more/getting_started/unix-variants.html
- Boost.Build documentation:
http://www.boost.org/build/doc/html/index.html
./b2
/Volumes/Data/Developers/Library/boost/tools/build/src/build/feature.jam:139: in feature.feature from module feature
error: unknown attributes: hidden
error: in feature declaration:
error: feature "deduced-address-model" : "32" "64" : "propagated" "optional" "composite" "hidden"
/Volumes/Data/Developers/Library/boost/boostcpp.jam:611: in load from module boostcpp
/Volumes/Data/Developers/Library/boost/tools/build/src/kernel/modules.jam:289: in modules.import from module modules
/Volumes/Data/Developers/Library/boost/tools/build/src/build/project.jam:1024: in import from module Jamfile</Volumes/Data/Developers/Library/boost>
Jamroot:124: in modules.load from module Jamfile</Volumes/Data/Developers/Library/boost>
/Volumes/Data/Developers/Library/boost/tools/build/src/build/project.jam:311: in load-jamfile from module project
/Volumes/Data/Developers/Library/boost/tools/build/src/build/project.jam:64: in load from module project
/Volumes/Data/Developers/Library/boost/tools/build/src/build/project.jam:145: in project.find from module project
/Volumes/Data/Developers/Library/boost/tools/build/src/build-system.jam:535: in load from module build-system
/Volumes/Data/Developers/Library/boost/tools/build/src/kernel/modules.jam:289: in import from module modules
/Volumes/Data/Developers/Library/boost/tools/build/src/kernel/bootstrap.jam:139: in boost-build from module
/Volumes/Data/Developers/Library/boost/boost-build.jam:17: in module scope from module
So can someone explain what this error means? How to fix it?
* Solution *
I forgot to update submodules, my fault
No that is really strange!
What commands are you passing to build? (or is that literally the default?)
I recommend trying out one of my build scripts here:
https://github.com/danoli3/ofxOSXBoost
If that doesn't work either it may be a system conflict.
Do you have Homebrew or Macports installed? See if they have a Boost version installed.
I have made a gulp project and I am trying to share it with a friend.
Its a simple css grid with gulp tasks integrated.
You can download the package here:
https://www.dropbox.com/s/od1dsh75tegbq24/projectfolder.zip?dl=1
When you unzip the package and make sure you have node.js, ruby and gulp.js installed and try to run the gulpfile, it throws the following error:
Cannot find module "semver-regex"
After I install that (npm install --save semver-regex)
It throws the same kind of error with:
Cannot find module "array-uniq"
After I install that, the build proces works, but liveReload and watch tasks don't...
Is there a way to share Gulpfiles without all the hassle? I just want it to be downloaded and used :)
Package.json is in the root:
{
"devDependencies": {
"gulp-minify-css": "^0.3.10",
"gulp-concat": "^2.4.1",
"gulp-uglify": "^1.0.1",
"gulp-imagemin": "^1.0.1",
"imagemin-pngcrush": "^1.0.0",
"gulp-sass": "^1.0.0",
"gulp-html-replace": "^1.3.0",
"gulp-connect": "^2.0.6",
"gulp-open": "^0.2.8",
"run-sequence": "^1.0.0",
"streamqueue": "^0.1.1"
}
}
I have to build latest release of chromium browser for android.
I am using the following step,
Create a Chromium root directory
mkdir chromium ; cd chromium
Download and export PATH of depot_tools
export PATH=$PATH:~/path/to/depot_tools/
Checked out the source for build 32.0.1665.2
gclient config https://src.chromium.org/chrome/releases/32.0.1665.2
4 The above command create a .gclient file in chromium root directory, and add the target android in .gclient.
target_os = ['android']
To download the initial code:
gclient sync
Install the Dependencies
6.1) cd /path/to/chromium/src
6.2) ./build/install-build-deps.sh
gclient runhooks call GYP to generate your platform-specific files. This should give you a complete source tree
gclient runhooks
Compile :
To build the ARM Android content shell:
1) cd /path/to/chromium/src
2) . build/android/envsetup.sh
3) android_gyp
4) ninja -C out/Release -j10 content_shell_apk
After following the above command i am getting the content_shell.apk which has version chrome/19.77.34.5, i am checking the version of chromium using the link http://whatsmyuseragent.com,
Please help me to build chromium latest version(32.0.1665.2) on android
Content shell does not display correct user agent version in android as well as linux (right now content_shell displays chrome/19.77.34.5).
This seems to be deliberate from src/content/content_shell.gypi
'variables': {
'content_shell_product_name': 'Content Shell',
# The "19" is so that sites that sniff for version think that this is
# something reasonably current; the "77.34.5" is a hint that this isn't a
# standard Chrome.
'content_shell_version': '**19.77.34.5**',
You can always use chromium_testshell which will give correct version (which is currently Chrome/35.0.1879.0).