ipfs / js-ipfs

IPFS implementation in JavaScript
https://js.ipfs.tech
Other
7.44k stars 1.25k forks source link

error `Non native build found` once I change the location of main in package.json to : `"main": ".webpack/main"`. Ipfs-Electron-Forge #3530

Closed raphael10-collab closed 3 years ago

raphael10-collab commented 3 years ago

I'm getting this error once I change the location of main in package.json to : "main": ".webpack/main", as suggested by the documentation: https://www.electronforge.io/config/plugins/webpack#project-setup

Error: No native build was found for platform=linux arch=x64 runtime=electron abi=85 uv=1 libc=glibc node=12.18.3 
electron=11.2.2 webpack=true
    loaded from: /home/marco/webMatters/electronMatters/ForgeElectron/.webpack/main

    at Function.module.exports../node_modules/node-gyp-build/index.js.load.path (/home/marco/webMatters/electronMatters
/ForgeElectron/.webpack/main/index.js:193884:9)
    at load (/home/marco/webMatters/electronMatters/ForgeElectron/.webpack/main/index.js:193846:30)
    at Object../node_modules/leveldown/binding.js (/home/marco/webMatters/electronMatters/ForgeElectron/.webpack
/main/index.js:130013:101)
    at __webpack_require__ (/home/marco/webMatters/electronMatters/ForgeElectron/.webpack/main/index.js:21:30)
    at Object../node_modules/leveldown/leveldown.js (/home/marco/webMatters/electronMatters/ForgeElectron/.webpack
/main/index.js:130127:17)
    at __webpack_require__ (/home/marco/webMatters/electronMatters/ForgeElectron/.webpack/main/index.js:21:30)
    at Object../node_modules/level/level.js (/home/marco/webMatters/electronMatters/ForgeElectron/.webpack
/main/index.js:130001:111)
    at __webpack_require__ (/home/marco/webMatters/electronMatters/ForgeElectron/.webpack/main/index.js:21:30)
    at new LevelDatastore (/home/marco/webMatters/electronMatters/ForgeElectron/.webpack/main/index.js:62303:23)
    at Object.createBackend [as create] (/home/marco/webMatters/electronMatters/ForgeElectron/.webpack
/main/index.js:111421:10)

This is the package.json :

{
  "name": "ForgeElectron",
  "description": "ForgeElectron",
  "version": "1.0.0",
  "main": ".webpack/main",
  "private": true,
  "scripts": {
    "start": "electron-forge start",
    "package": "electron-forge package",
    "make": "electron-forge make",
    "publish": "electron-forge publish",
    "lint": "eslint --ext .ts ."
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/raphael10-collab/ForgeElectron"
  },
  "license": "MIT",
  "config": {
    "forge": "./tools/forge/forge.config.js"
  },
  "devDependencies": {
    "@electron-forge/cli": "^6.0.0-beta.54",
    "@electron-forge/maker-deb": "^6.0.0-beta.54",
    "@electron-forge/maker-rpm": "^6.0.0-beta.54",
    "@electron-forge/maker-squirrel": "^6.0.0-beta.54",
    "@electron-forge/maker-zip": "^6.0.0-beta.54",
    "@electron-forge/plugin-webpack": "^6.0.0-beta.54",
    "@types/react": "^17.0.1",
    "@types/react-dnd": "^3.0.2",
    "@types/react-dnd-html5-backend": "^3.0.2",
    "@types/react-dom": "^17.0.0",
    "@types/webpack-env": "^1.16.0",
    "@typescript-eslint/eslint-plugin": "^4.14.2",
    "@typescript-eslint/parser": "^4.14.2",
    "copy-webpack-plugin": "^7.0.0",
    "cross-env": "^7.0.3",
    "electron": "^11.2.2",
    "electron-rebuild": "^2.3.4",
    "eslint": "^7.19.0",
    "eslint-import-resolver-alias": "^1.1.2",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-react": "^7.22.0",
    "fork-ts-checker-webpack-plugin": "^6.1.0",
    "ipfs": "^0.54.1",
    "less": "^4.1.1",
    "node-loader": "^1.0.2",
    "react-hot-loader": "^4.13.0",
    "test-ipfs-example": "^2.0.3",
    "ts-loader": "^8.0.14",
    "typescript": "^4.1.3",
    "webpack": "4"
  },
  "greenkeeper": {
    "ignore": [
      "electron"
    ]
  },
  "dependencies": {
    "@hot-loader/react-dom": "^17.0.1",
    "electron-squirrel-startup": "^1.0.0",
    "ipfs-http-client": "^49.0.1",
    "ipfs-utils": "^6.0.0",
    "react": "^17.0.1",
    "react-dnd": "^11.1.3",
    "react-dnd-html5-backend": "^11.1.3"
  }
}

In order to better spot and solve the problem, I've put the code here: https://github.com/raphael10-collab/ForgeElectron Just git clone -> yarn -> yarn install

I do not know if it's a problem which has to be solved by "Electron-Forge people" or by "Ipfs people". But it's a fact that this problem arises when using Ipfs with Electron-Forge

I opened an issue also in the GitHub's Electron-Forge page: https://github.com/electron-userland/electron-forge/issues/2146

achingbrain commented 3 years ago

Your webpack configuration is broken. A cursory web search led me to this: https://github.com/Level/leveldown/issues/725#issuecomment-755205501 - it makes the No native build error go away for me.

raphael10-collab commented 3 years ago

@achingbrain

Thank you. Unfortunately this solves partially but not completely.

Once set in webpack.main.js:

node: {
  global: true,
  __dirname: true,
  __filename: true
}

if in package.json the main path is set to:

"main": "./.webpack/main"

I get no error but the ipfs peers disappear :

image

If I set main path to "main": "src/main.ts" then the ipfs working comes back

image

But, according to the Electron-Forge documentation the main path has to be set to ./.webpack/main : https://www.electronforge.io/config/plugins/webpack#project-setup