microsoft / napajs

Napa.js: a multi-threaded JavaScript runtime

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

napajs can not run in electron

Tomyail opened this issue · comments

I clone https://github.com/electron/electron-quick-start , add napa and electron-rebuild to rebuild napa,but when I run electron ,it throw error with

Error: The module '/Users/lixuexin/electron-quick-start/node_modules/napajs/bin/napa-binding.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 54. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or`npm install`).
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
    at Object.Module._extensions..node (module.js:598:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/lixuexin/electron-quick-start/node_modules/napajs/lib/binding.js:22:22)
    at Object.<anonymous> (/Users/lixuexin/electron-quick-start/node_modules/napajs/lib/binding.js:27:3)

electron-rebuild works well with my own addon.
here is the package.json

{
  "name": "electron-quick-start",
  "version": "1.0.0",
  "description": "A minimal Electron application",
  "main": "main.js",
  "scripts": {
    "start": "electron .",
    "rebuild": "electron-rebuild -f && electron ."
  },
  "repository": "https://github.com/electron/electron-quick-start",
  "keywords": [
    "Electron",
    "quick",
    "start",
    "tutorial",
    "demo"
  ],
  "author": "GitHub",
  "license": "CC0-1.0",
  "devDependencies": {
    "electron": "~1.7.8"
  },
  "dependencies": {
    "electron-rebuild": "^1.6.0",
    "napajs": "^0.1.7"
  }
}

Hi, @Tomyail,
Which version of Node are you using? Is it a customized versions? You may check it by "node -v".
We can find

  • NODE_MODULE_VERSION is 51 for all node v7..
  • NODE_MODULE_VERSION is 57 for all node v8..
  • NODE_MODULE_VERSION is 59 for all node v9..
    In the error message you provide, NODE_MODULE_VERSION 54.
    I would recommend to try it again with a standard node version. Because Napa.js provides pre-built bins only for them.
    For other versions of node, developers need to recompile it from their client.

Best regards, and Merry Christmas!
Allen.

@helloshuangzi the node is bundle in electron , so i can't change this version. I use this link and get the follow info:

{
    "http_parser": "2.7.0", 
    "node": "7.9.0", 
    "v8": "5.8.283.38", 
    "uv": "1.11.0", 
    "zlib": "1.2.11", 
    "ares": "1.10.1-DEV", 
    "modules": "54", 
    "openssl": "1.0.2k", 
    "electron": "1.7.10", 
    "chrome": "58.0.3029.110", 
    "atom-shell": "1.7.10"
}

and I will try compile napa from source

@Tomyail I've added a new wiki page at https://github.com/Microsoft/napajs/wiki/Build-Napa.js-for-Electron. Please let me know if you have any questions.

@fs-eire thanks , it works!