Node-sass: Building node-sass for Electron v1.6.11

Created on 26 Jul 2017  ·  20Comments  ·  Source: sass/node-sass

I tried doing npm run-script build, but that builds the binary for darwin-x64-51 when I need darwin-x64-53 for Electron.

I also tried:

node scripts/build.js --target 1.6.11 --target_arch x64 --dist-url https://atom.io/download/electron --sass-binary-path $PWD/vendor/darwin-x64-53

..which failed with:

/Users/aleclarson/modules/node-sass/vendor/darwin-x64-53 not found

Any pointers would be appreciated!

Versions

  • node-sass version: 4.5.3
  • Electron version: 1.6.11
  • Node version: 7.4.0
  • Node modules version: 53
  • Node platform: darwin

Most helpful comment

@aleclarson Thanks, it worked for me for macOS and electron 1.6.12. I've improved the script a bit to automate it:

#!/bin/bash

set -e
ARCH="x64"
TARGET=$(node -e "console.log(require('./package.json').devDependencies.electron.match(/\d+\.\d+.\d+/)[0])")
PLATFORM=$(node -e "console.log(process.platform)")

cd node_modules/node-sass/

# Build for Electron for current version
node-gyp rebuild --target=$TARGET --arch=$ARCH --dist-url=https://atom.io/download/electron

# Create vendor directory
VENDOR="vendor/$PLATFORM-$ARCH-53"
mkdir -p $VENDOR
cp build/Release/binding.node $VENDOR

cd ../../

# Clean up
rm -rf build

All 20 comments

Perhaps I should be following this guide. I'll try a few things, but any help would be awesome.

The first thing I tried:

node-gyp rebuild --target=1.6.11 --arch=x64 --dist-url=https://atom.io/download/electron

No errors, but no vendor/darwin-x64-53 directory was created.

Then I tried require('./scripts/build') from inside Electron dev tools, but an error was thrown.

Build failed with error code: 1

The build process was spawned with:

/Users/aleclarson/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Helper.app/Contents/MacOS/Electron Helper /Users/aleclarson/modules/node-sass/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=

Mission accomplished. 🚀

# Build for Electron v1.6.11
ARCH="x64"
node-gyp rebuild --target=1.6.11 --arch=$ARCH --dist-url=https://atom.io/download/electron

# Create vendor directory
VENDOR="vendor/darwin-$ARCH-53"
mkdir $VENDOR
cp build/Release/binding.node $VENDOR

# Clean up
rm -rf build

edit: I whipped up a script you may find useful: https://gist.github.com/aleclarson/71ddec23c9e9ca3679f75c17addb1a44

It seems that this method does not work~ @aleclarson

@xp6530 I can help if you provide your OS version, Electron version, node-gyp version, which method you tried, and what error (if any) was logged. 👍

@aleclarson
I also want an runtime (53) file for my proiect on widows .
How do I rebuild it?

ARCH="x64"
node-gyp rebuild --target=1.6.11 --arch=$ARCH --dist-url=https://atom.io/download/electron

When I run the ablove code in CMD, it reminde me : ARCH: unknown option -- target=1.6.11

node : 6.11.0
node-gyp: 3.6.2
electron: 1.6.11
electron-rebuild:1.6.0

@cdswyda I'm not familiar with the command line nuances of Windows, but I know for sure that --target is a valid option (see here). Maybe you need to wrap it in quotes? ¯\_(ツ)_/¯

@aleclarson Thanks, it worked for me for macOS and electron 1.6.12. I've improved the script a bit to automate it:

#!/bin/bash

set -e
ARCH="x64"
TARGET=$(node -e "console.log(require('./package.json').devDependencies.electron.match(/\d+\.\d+.\d+/)[0])")
PLATFORM=$(node -e "console.log(process.platform)")

cd node_modules/node-sass/

# Build for Electron for current version
node-gyp rebuild --target=$TARGET --arch=$ARCH --dist-url=https://atom.io/download/electron

# Create vendor directory
VENDOR="vendor/$PLATFORM-$ARCH-53"
mkdir -p $VENDOR
cp build/Release/binding.node $VENDOR

cd ../../

# Clean up
rm -rf build

@cdswyda in your windows, It work? Can you help me? Thank you very much. I recompiled node-sass but I made a mistake:

Error: Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (50)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.5.3
at module.exports (J:\project\BrickFlow\node_modules\node-sass\lib\binding.js:13:13)
at Object. (J:\project\BrickFlow\node_modules\node-sass\lib\index.js:14:35)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object. (J:\project\BrickFlow\node_modules\gulp-sass\index.js:187:21)

my system is windows 10.
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
electron: 1.7.6

@pro-w-xuan I'm sorry. It doesn't work on my windows computer. I use stylus instead of sass,only need to use '=' replace ':' in sass file.
but some specific syntax can't use in stylus.

@cdswyda Thank you for your reply, I haven't solve this

@gimenete Thank you very much, I use your script build this successfully.

@pro-w-xuan Have you solved this problem ? with gimenete's script ,it works well.

#!/bin/bash

set -e
ARCH="x64"
TARGET=$(node -e "console.log(require('./package.json').devDependencies.electron.match(/\d+\.\d+.\d+/)[0])")
PLATFORM=$(node -e "console.log(process.platform)")

cd node_modules/node-sass/

# Build for Electron for current version
node-gyp rebuild --target=$TARGET --arch=$ARCH --dist-url=https://atom.io/download/electron

# Create vendor directory
VENDOR="vendor/$PLATFORM-$ARCH-54"
mkdir -p $VENDOR
cp build/Release/binding.node $VENDOR

cd ../../

# Clean up
rm -rf build

Make above content in a .sh file, then run it in Git Bash.

@pro-w-xuan @cdswyda the error is telling you the API version you need to use when compiling:

Error: Node Sass does not yet support your current environment:
    Windows 64-bit with Unsupported runtime (50)

In this case it's 50. Use that in the VENDOR declaration:

VENDOR="vendor/$PLATFORM-$ARCH-50"

Now that I'm using electron 1.7.x for me it's 54.

Thanks for the script @gimenete, I was able to get node-sass working with electron 3.0.6 (using runtime 64). I've been stuck on this for a while now, it's good to finally get it working.

The error I was getting is:

dyld: lazy symbol binding failed: Symbol not found: __ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorENS_14SideEffectTypeE
  Referenced from: /node_modules/node-sass/vendor/darwin-x64-64/binding.node
  Expected in: flat namespace

@alex-i-n I have the same issue with node-sass you described. What were the exact steps you followed? Did you build node-sass for your platform?

@georgschlenkhoff I used the script provided by @gimenete and replaced VENDOR="vendor/$PLATFORM-$ARCH-53" with VENDOR="vendor/$PLATFORM-$ARCH-64".

Sorry for being so late to respond, didn't notice the GH notification.

Thanks for the scripts and following of this topic, this script got it working on macOS Catalina. But does anyone know how does this works with electron-rebuild—could get overwrote if run after or later?

@pabliqe IIRC yes, electron-rebuild will overwrite the "custom" binding and you'll have to run the script again. It's been a while since I messed around with it so perhaps try it for yourself, it might work for you.

Was this page helpful?
0 / 5 - 0 ratings