Node-sass: Problem with using node-sass alongside electron on Ubuntu 16.04

Created on 27 Aug 2016  路  17Comments  路  Source: sass/node-sass

I am using node-sass alongside electronin Ubuntu 16.04. When I run electron . inside my project, I get following error:

A JavaScript error occurred in the main process
Uncaught Exception:
Error: Node Sass does not yet support your current environment: Linux 64-bit with Unsupported runtime (49)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v3.8.0

There is no problem, however, when I run the same command on Ubuntu 15.04.

I have latest version of node and node-sass (at the time of posting this issue).

Any idea?

Most helpful comment

We actually could rebuild node-sass against Electron version. I'm successfully rebuild with following steps :

  1. Follow these steps https://github.com/sass/node-sass#rebuilding-binaries until npm install don't need to run last step (node scripts/build -f)
  2. In node-sass directory run following :
    HOME=~/.electron-gyp ./node_modules/node-gyp/bin/node-gyp.js rebuild --target=1.3.4 --arch=x64 --dist-url=https://atom.io/download/atom-shell --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library= -- Note that I'm using Electron version 1.3.4, you can change with your Electron version.
  3. The output will be inside build/Release/binding.node Then you can copy that file into your node_modules/node-sass/vendor/darwin-x64-49 folder. -- Note that I'm using darwin-x-64-49, you should match this with your environment. Mine is :
    OSX 64bit with Electron v1.3.4 (this version using API 49, more info )

All 17 comments

Also see the last comment in this thread: https://github.com/electron-userland/electron-prebuilt/issues/172

This problem _might_ be resolved once the next node version is out with V8 5.1, and node-sass has been updated to support it. Hopefully then things will work better with Electron once the V8 versions align.

As the message says, Electron isn't a supported platform

@nschonni So why there isn't any problem in Ubuntu 15.04?

Electron does some weird things that make it incompatible it prebuilt binaries. I believe they're working on addressing the problems. In this case they're supplying a version number (49) that we don't support.

This may be addressed when a version of node is released with module version 49.

As stated in https://github.com/electron/electron/issues/5851 you'll need to wait until node ships v8 5.1. You could try using electron rebuild but I don't believe there is a version of nan that is compatible with v8 5.1 so I expect it'll fail.

@nschonni Apart from questions of manpower/womanpower needed to support node-sass on Electron, are there any hard technical reasons why it wouldn't work?

@sedwards2009 One thing to check is whether electron and node modules for one V8 API can be treated as compatible (do we need separate bindings for electron and node).

@saper I haven't been able to find evidence either way, but I think it is reasonable to assume that modules for node and electron are the same given the same V8 version.

The reason why Electron sometimes goes a bit weird with respect to modules is that they upgrade their Chromium version quite quickly and have little choice but to use the version of V8 bound to that Chromium, which doesn't always correspond with the latest node release. (node updates a bit slower and gets the newest V8 a bit later.)

I've had a closer look at this. Last night I patched the extensions.js to accept 49 as a module version, and build.js to pass the right parameters to node-gyp (basically stuff to fetch the right headers). I then built a binary binding.node moved it to the right place and it worked! I can import it, renderSync() works, render() works and the import hook also seems to work ok too. (This is on a Linux x64.)

Interesting to know: Electron 1.3.x uses V8 module API 49. Node 6.5 is still on API 48. It looks like the next release of Node will be v7.0.0 and the node gang plan to jump straight up to the latest V8 with API 52 (or something like that, basically leap-frogging over 49 entirely.)

I'll put my changes up somewhere on github soon. It needs to be a bit neater first.

We actually could rebuild node-sass against Electron version. I'm successfully rebuild with following steps :

  1. Follow these steps https://github.com/sass/node-sass#rebuilding-binaries until npm install don't need to run last step (node scripts/build -f)
  2. In node-sass directory run following :
    HOME=~/.electron-gyp ./node_modules/node-gyp/bin/node-gyp.js rebuild --target=1.3.4 --arch=x64 --dist-url=https://atom.io/download/atom-shell --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library= -- Note that I'm using Electron version 1.3.4, you can change with your Electron version.
  3. The output will be inside build/Release/binding.node Then you can copy that file into your node_modules/node-sass/vendor/darwin-x64-49 folder. -- Note that I'm using darwin-x-64-49, you should match this with your environment. Mine is :
    OSX 64bit with Electron v1.3.4 (this version using API 49, more info )

@hdytsgt thank you for this! I've been struggling for hours trying to get node-sass working with Electron on Windows, and your step 3 was the last piece I was missing.

I was able to use electron-rebuild in place of step 2, but it doesn't handle the necessary step 3.

@dvanoni can you suggest me how to rebuild node-sass on window for electron?

@hiepxanh it's been a while now since I've done it, but these are the steps I had written down for myself.

Rebuild node-sass explicitly using electron-rebuild:

.\node_modules\.bin\electron-rebuild -o node-sass

Copy the generated binding.node file to the necessary directory:

copy .\node_modules\node-sass\build\Release\binding.node .\node_modules\node-sass\vendor\win32-x64-57\

Note that this depends on the version of Electron you're using as mentioned above. i.e. you would need to replace the win32-x64-57 part to match your version. I also had a note for myself that this directory may need to be manually created if it doesn't exist.

@dvanoni sir, please help me, my enviroment Module version is 64, but require electron is 69. how I can specific that ?? It very important for me to write this plugin, I will be very appreciate if you can help me sir
image

I already try to rename from win32-x64-64 to win32-x64-69 but it not success
image

oh my god @dvanoni I can fix it finally
first add this to package.json
step 1: add build configuration for electron
``` .json
"build": {
"buildDependenciesFromSource": "true",
"npmRebuild": "false"
},

`` step 2: then runnpm i electron-builder electron-rebuild [email protected] -D`

step 3: run .\node_modules\.bin\electron-rebuild.cmd -f or .\node_modules\.bin\electron-rebuild.cmd -f -o node-sass

step 4: Copy the generated binding.node file to the necessary directory (as @dvanoni and @hdytsgt metion):
copy: node-sass\bin\win32-x64-69\node-sass.node to {{target node-sass folder}}\node-sass\vendor\win32-x64-69\node-sass.node
and copy: node-sass\build\Release\binding.node to {{target node-sass folder}}\node-sass\vendor\win32-x64-69\

that all thank all of you, have a nice day

Was this page helpful?
0 / 5 - 0 ratings