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

electron-builder with opencv4nodejs doesn't set him the right install directory #141

Open
sollosollo4 opened this issue Jun 2, 2024 · 5 comments

Comments

@sollosollo4
Copy link

problem description: I'm running the electron application and found that it works correctly with @u4/opencv4nodejs (no errors on startup). after which I create a program installer using electron-builder, transfer this installer to another PC, install the program - it installs correctly. When I start the program I get the error: opencv binary does not exist. after which, it shows me the path along which he is trying to get opencv binary, equal to the path where he launched it from the developer’s PC (C:\some_directories\project\node_modules@u4\opencv-build\dist\latest\build\bin\Release )
image
What am I doing?
I have an electron+react application. I'm using @u4/opencv-build to auto build opencv.
Before packing I do the following:
I already have a ready to go build opencv directory generated with:
npx build-opencv --electron --nocontrib rebuild
This works correctly for
"autoBuildOpencvVersion": "4.8.0" + "electron": "^28.0.0"
"electron-builder": "^24.9.1"
"electron-rebuild": "^3.2.9"
After which, I prepare the react and electron directories:
"build-react": "react-scripts build",
"build-electron": "mkdir build/electron & mkdir build/opencv & robocopy electron build/electron /S",
npm run build-react
npm run build-electron
After which all I have to do is create a packer using the electron-builder utility
"package": "electron-builder build --win --publish never",
npm run package
I get a dist folder in which I have the following structure:
image
But I see how electron-builder tried to package it inside the project. but he's still doing it wrong.
image
Unfortunately, I’ve given up and can’t do it in any way. After all, my application in any case looks for the library in the wrong path, and I haven’t found a way to configure this manually.
Here is my package.json

{
  "name": "albion-overlay",
  "author": "sollosollo4",
  "description": "An overlay program that will help you monitor cooldown of your friends abilities.",
  "version": "0.1.0",
  "private": true,
  "main": "electron/electron.js",
  "productName": "AlbionOverlay",
  "homepage": "./",
  "dependencies": {
    "@testing-library/jest-dom": "^5.17.0",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "@types/react": "^18.2.42",
    "@types/react-dom": "^18.2.17",
    "@u4/opencv-build": "^0.7.8",
    "@u4/opencv4nodejs": "^6.5.2",
    "axios": "^1.6.5",
    "electron-overlay-window": "^3.3.0",
    "pusher-js": "^8.4.0-rc2",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-router-dom": "^6.20.1",
    "react-scripts": "^5.0.1",
    "styled-components": "^6.1.1",
    "throttle-debounce": "^5.0.0",
    "web-vitals": "^2.1.4"
  },
  "opencv4nodejs": {
    "autoBuildOpencvVersion": "4.8.0"
  },
  "scripts": {
    "start": "set BROWSER=none&& react-scripts start",
    "electron": "set ELECTRON_START_URL=http://localhost:3000 && electron .",
    "react-start": "react-scripts start",
    "react-test": "react-scripts test --env=jsdom",
    "react-eject": "react-scripts eject",
    "build-react": "react-scripts build",
    "build-electron": "mkdir build/electron & mkdir build/opencv & robocopy electron build/electron /S",
    "package": "electron-builder build --win --publish never",
    "opencv-build": "build-opencv --electron --nocontrib rebuild",
    "opencv-npm-build": "opencv-build-npm --nocontrib --electron"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "electron": "^28.0.0",
    "electron-builder": "^24.9.1",
    "electron-rebuild": "^3.2.9",
    "laravel-echo": "^1.15.3"
  },
  "build": {
    "appId": "com.sollosollo4.albion-overlay",
    "productName": "AlbionOverlay",
    "directories": {
      "output": "dist"
    },
    "files": [
      "./build/*",
      "./node_modules/**/*"
    ],
    "extraMetadata": {
      "main": "./build/electron/electron.js"
    },
    "nsis": {
      "oneClick": false,
      "perMachine": true,
      "allowToChangeInstallationDirectory": true,
      "menuCategory": "Albion Overlay",
      "createDesktopShortcut": true,
      "createStartMenuShortcut": true
    }
  }
}
@sollosollo4
Copy link
Author

right now I found buildRoot interesting, maybe if I specify it..

@sollosollo4
Copy link
Author

Still have issue. I dont know how to package it correctly

@studentutu
Copy link

maybe the same issue -
npm error gyp: Call to 'node ./bin/install.js OPENCV4NODEJS_DEFINES' returned exit status 1 while in binding.gyp. while trying to load binding.gyp

Tried to install opencv and cmake via choco - didn't helped
Tried re-install node-gyp: npx node-gyp install - didn't helped
Tried removing all caches ( windows local/appdata and from electron/node-packages) - didn't helped

Being hopeless, tried install via pnpm - pnpm install @u4/opencv4nodejs and it finally worked!
I don't know why it workes with pnpm and not with npm.

@sollosollo4
Copy link
Author

@studentutu I don't know, it seems like you have something different. here is an issue in which I was able to figure out how to install this, but my problem lies precisely in the package in the installation file
#121

@whitetigle
Copy link

maybe the same issue - npm error gyp: Call to 'node ./bin/install.js OPENCV4NODEJS_DEFINES' returned exit status 1 while in binding.gyp. while trying to load binding.gyp

Tried to install opencv and cmake via choco - didn't helped Tried re-install node-gyp: npx node-gyp install - didn't helped Tried removing all caches ( windows local/appdata and from electron/node-packages) - didn't helped

Being hopeless, tried install via pnpm - pnpm install @u4/opencv4nodejs and it finally worked! I don't know why it workes with pnpm and not with npm.

Same here except pnpm giv the same gyp: Call to 'node ./bin/install.js OPENCV4NODEJS_DEFINES' returned exit status 1 error.

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

3 participants