webtorrent / webtorrent-hybrid

WebTorrent (with WebRTC support in Node.js)
https://webtorrent.io
MIT License
519 stars 98 forks source link

Error: Was compiled against a different Node.js version using #95

Closed GilGustavoJ closed 5 years ago

GilGustavoJ commented 5 years ago

OS Ubuntu 18.04 LTS

This is my package.json

{
  "name": "cotufas",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "electron main.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "electron": "^4.1.4",
    "webtorrent": "^0.103.1",
    "webtorrent-hybrid": "^2.1.0"
  }
}

My main.js

const electron = require('electron')
const webtorrent = require('webtorrent')
const webtorrent_hybrid = require('webtorrent-hybrid')
const {app, BrowserWindow} = electron

const path = require('path')
const url = require('url')

let win

let BrowserWindowOptions

function createWindow(){

    /* Establecemos las opciones de la ventana */
    BrowserWindowOptions = {
        show: false,
        background: '#212121', 
        center: true, 
        minWidth: 1024, 
        minHeight: 768,
        autoHideMenuBar: true,
        webPreferences: {
            nodeIntegration: true
        }
    }

    /* Iniciamos una nueva ventana */
    win = new BrowserWindow(BrowserWindowOptions)

    /* Cargamos la plantilla html la cual se mostrara en el Window */
    win.loadURL(url.format({
        pathname: path.join(__dirname, 'templates/home/index.html'),
        protocol: 'file',
        slashes: true
    }))

    /* Evitamos que se muestre la aplicacion en blanco */
    win.on('ready-to-show', () => {

        /* Agrandamos la ventana a la resolución de la pantalla */
        win.maximize()

        /* Mostramos la ventana cuando se tenga todo cargado */
        win.show()

        /* Developers */
        win.webContents.openDevTools()

    })

    /* Evento al cerrar la ventana */
    win.on('closed', () => {
        win = null
    })
}

/* Iniciamos nuestra aplicación */
app.on('ready', createWindow)

I am developing an application with Electron. The application is a Web Torrent Player. When executing npm start from the Linux console it shows the following error:

A JavaScript error occurred in the main process
Uncaught Exception:
Error: The module '/var/www/html/cotufas.js/node_modules/wrtc/build/Release/wrtc.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 69. 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:160:31)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:722:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:160:31)
    at Module.load (internal/modules/cjs/loader.js:602:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:541:12)
    at Function.Module._load (internal/modules/cjs/loader.js:533:3)
    at Module.require (internal/modules/cjs/loader.js:640:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/var/www/html/cotufas.js/node_modules/wrtc/lib/binding.js:6:20)
    at Object.<anonymous> (/var/www/html/cotufas.js/node_modules/wrtc/lib/binding.js:9:3)
DiegoRBaquero commented 5 years ago

Try npm rebuild wrtc --update-binary

GilGustavoJ commented 5 years ago

@DiegoRBaquero Execute the command, but at the moment of execution npm start it shows the same error

A JavaScript error occurred in the main process
Uncaught Exception:
Error: The module '/var/www/html/cotufas.js/node_modules/wrtc/build/Release/wrtc.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 69. 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:160:31)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:722:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:160:31)
    at Module.load (internal/modules/cjs/loader.js:602:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:541:12)
    at Function.Module._load (internal/modules/cjs/loader.js:533:3)
    at Module.require (internal/modules/cjs/loader.js:640:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/var/www/html/cotufas.js/node_modules/wrtc/lib/binding.js:6:20)
    at Object.<anonymous> (/var/www/html/cotufas.js/node_modules/wrtc/lib/binding.js:9:3)
DiegoRBaquero commented 5 years ago

Hmmmm, weird. Don't really know what can help then :S

GilGustavoJ commented 5 years ago

@DiegoRBaquero Execute the command, but at the moment of execution npm start it shows the same error

A JavaScript error occurred in the main process
Uncaught Exception:
Error: The module '/var/www/html/cotufas.js/node_modules/wrtc/build/Release/wrtc.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 69. 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:160:31)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:722:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:160:31)
    at Module.load (internal/modules/cjs/loader.js:602:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:541:12)
    at Function.Module._load (internal/modules/cjs/loader.js:533:3)
    at Module.require (internal/modules/cjs/loader.js:640:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/var/www/html/cotufas.js/node_modules/wrtc/lib/binding.js:6:20)
    at Object.<anonymous> (/var/www/html/cotufas.js/node_modules/wrtc/lib/binding.js:9:3)

This is the output at the moment to execute npm rebuild wrtc --update-binary


> wrtc@0.3.7 install /var/www/html/cotufas.js/node_modules/wrtc
> node scripts/install.js

Searching for a pre-built wrtc binary
node-pre-gyp WARN Using request for node-pre-gyp https download 
[wrtc] Success: "/var/www/html/cotufas.js/node_modules/wrtc/build/Release/wrtc.node" is installed via remote
Installed a pre-built wrtc binary
wrtc@0.3.7 /var/www/html/cotufas.js/node_modules/wrtc
DiegoRBaquero commented 5 years ago

So the binary does get updated. Huh. weird, Node.js version?

GilGustavoJ commented 5 years ago

So the binary does get updated. Huh. weird, Node.js version?

Node Version: 10.15.3

feross commented 5 years ago

You shouldn't need to use webtorrent-hybrid or compile wrtc if you're using Electron. Electron already has WebRTC built into it's renderer processes. You'll have a much happier time if you just use the webtorrent package directly in Electron.