Giter VIP home page Giter VIP logo

rebuild's Introduction

Electron Rebuild

CircleCI NPM Coverage Status

This executable rebuilds native Node.js modules against the version of Node.js that your Electron project is using. This allows you to use native Node.js modules in Electron apps without your system version of Node.js matching exactly (which is often not the case, and sometimes not even possible).

How does it work?

Install the package with --save-dev:

npm install --save-dev @electron/rebuild

Then, whenever you install a new npm package, rerun electron-rebuild:

$(npm bin)/electron-rebuild

Or if you're on Windows:

.\node_modules\.bin\electron-rebuild.cmd

If you have a good node-gyp config but you see an error about a missing element on Windows like Could not load the Visual C++ component "VCBuild.exe", try to launch electron-rebuild in an npm script:

"scripts": {
  "rebuild": "electron-rebuild -f -w yourmodule"
}

and then

npm run rebuild

What are the requirements?

Node v12.13.0 or higher is required. Building native modules from source uses node-gyp, refer to the link for its installation/runtime requirements.

CLI Arguments

Usage: electron-rebuild --version [version] --module-dir [path]

Options:
  -h, --help                   Show help                               [boolean]
  -v, --version                The version of Electron to build against
  -f, --force                  Force rebuilding modules, even if we would skip
                               it otherwise
  -a, --arch                   Override the target architecture to something
                               other than your system's
  -m, --module-dir             The path to the app directory to rebuild
  -w, --which-module           A specific module to build, or comma separated
                               list of modules. Modules will only be rebuilt if they
                               also match the types of dependencies being rebuilt
                               (see --types).
  -e, --electron-prebuilt-dir  The path to the prebuilt electron module
  -d, --dist-url               Custom header tarball URL
  -t, --types                  The types of dependencies to rebuild.  Comma
                               separated list of "prod", "dev" and "optional".
                               Default is "prod,optional"
  -p, --parallel               Rebuild in parallel, this is enabled by default
                               on macOS and Linux
  -s, --sequential             Rebuild modules sequentially, this is enabled by
                               default on Windows
  -o, --only                   Only build specified module, or comma separated
                               list of modules. All others are ignored.
  -b, --debug                  Build debug version of modules
  --prebuild-tag-prefix        GitHub tag prefix passed to prebuild-install.
                               Default is "v"

Copyright 2016

How can I use this with Electron Forge?

This package is automatically used with Electron Forge when packaging an Electron app.

How can I integrate this into Electron Packager?

electron-rebuild provides a function compatible with the afterCopy hook for Electron Packager. For example:

import packager from '@electron/packager';
import rebuild from '@electron/rebuild';

packager({
  // … other options
  afterCopy: [(buildPath, electronVersion, platform, arch, callback) => {
    rebuild({ buildPath, electronVersion, arch })
      .then(() => callback())
      .catch((error) => callback(error));
  }],
  // … other options
});

How can I integrate this with prebuild?

If your module uses prebuild for creating prebuilt binaries, it also uses prebuild-install to download them. If this is the case, then electron-rebuild will run prebuild-install to download the correct binaries from the project's GitHub Releases instead of rebuilding them.

How can I integrate this into Grunt / Gulp / Whatever?

electron-rebuild is also a library that you can require into your app or build process. It has a very simple API:

import rebuild from '@electron/rebuild';

// Public: Rebuilds a node_modules directory with the given Electron version.
//
// options: Object with the following properties
//     buildPath - An absolute path to your app's directory.  (The directory that contains your node_modules)
//     electronVersion - The version of Electron to rebuild for
//     arch (optional) - Default: process.arch - The arch to rebuild for
//     extraModules (optional) - Default: [] - An array of modules to rebuild as well as the detected modules
//     onlyModules (optional) - Default: null - An array of modules to rebuild, ONLY these module names will be rebuilt.
//                                              The "types" property will be ignored if this option is set.
//     force (optional) - Default: false - Force a rebuild of modules regardless of their current build state
//     headerURL (optional) - Default: https://www.electronjs.org/headers - The URL to download Electron header files from
//     types (optional) - Default: ['prod', 'optional'] - The types of modules to rebuild
//     mode (optional) - The rebuild mode, either 'sequential' or 'parallel' - Default varies per platform (probably shouldn't mess with this one)
//     useElectronClang (optional) - Whether to use the clang executable that Electron used when building its binary. This will guarantee compiler compatibility

// Returns a Promise indicating whether the operation succeeded or not

A full build process might look something like:

const childProcess = require('child_process');
const pathToElectron = require('electron');

  rebuild({
    buildPath: __dirname,
    electronVersion: '1.4.12'
  })
    .then(() => console.info('Rebuild Successful'))
    .catch((e) => {
      console.error("Building modules didn't work!");
      console.error(e);
    });

rebuild's People

Contributors

abread avatar albinekb avatar anaisbetts avatar benogle avatar ckerr avatar dependabot[bot] avatar dsanders11 avatar electron-roller[bot] avatar enlight avatar felicienfrancois avatar hipsterbrown avatar hongrich avatar kevinsawicki avatar malept avatar marshallofsound avatar maxkorp avatar mmaietta avatar mnaamani avatar mojodna avatar refractalize avatar romaincointepas avatar samuelmaddock avatar smashwilson avatar sphire avatar timfish avatar vertedinde avatar vovkasm avatar will-stone avatar zcbenz avatar zeke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rebuild's Issues

Error building zmq package on Windows

Hi,

I'm trying to use electron shell with zmq.

When I try to use zmq in my electron shell app after installing via "npm install zmq", I get an error:

C:\Projects\snom-client>node_modules\.bin\electron.cmd .
[62752:0825/141645:INFO:CONSOLE(0)] App threw an error when running [Error: A dynamic link library (DLL) i
nitialization routine failed.
C:\Projects\snom-client\node_modules\zmq\build\Release\zmq.node]

After reading trough the docs on native modules (http://electron.atom.io/docs/v0.31.0/tutorial/using-native-node-modules/), I tried the "easy" method to get electron running with the native zmq module via electron-rebuild. This leads to some cryptic warnings and errors:

C:\Projects\snom-client>node_modules\.bin\electron-rebuild.cmd

> [email protected] install C:\Projects\snom-client\node_modules\zmq
> node-gyp rebuild


C:\Projects\snom-client\node_modules\zmq>if not defined npm_config_node_gyp (node "C:\Projects\snom-client
\node_modules\electron-rebuild\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp
.js" rebuild )  else (node  rebuild )
  binding.cc
C:\Projects\snom-client\node_modules\zmq\node_modules\nan\nan.h(263): error C2995: 'v8::Local<T> _NanEnsur
eLocal(v8::Local<T>)': function template has already been defined [C:\Projects\snom-client\node_modules\zm
q\build\zmq.vcxproj]
  C:\Projects\snom-client\node_modules\zmq\node_modules\nan\nan.h(256): note: see declaration of '_NanEnsu
reLocal'
C:\Projects\snom-client\node_modules\zmq\node_modules\nan\nan.h(661): error C3083: 'smalloc': the symbol t
o the left of a '::' must be a type [C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
C:\Projects\snom-client\node_modules\zmq\node_modules\nan\nan.h(661): error C2039: 'FreeCallback': is not
a member of 'node' [C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
  C:\Projects\snom-client\node_modules\electron-rebuild\lib\headers\.node-gyp\0.31.0\src\node_object_wrap.
h(8): note: see declaration of 'node'
C:\Projects\snom-client\node_modules\zmq\node_modules\nan\nan.h(661): error C2061: syntax error: identifie
r 'FreeCallback' [C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
C:\Projects\snom-client\node_modules\zmq\node_modules\nan\nan.h(665): error C2065: 'callback': undeclared
identifier [C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
C:\Projects\snom-client\node_modules\zmq\node_modules\nan\nan.h(665): error C2065: 'hint': undeclared iden
tifier [C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
C:\Projects\snom-client\node_modules\zmq\node_modules\nan\nan.h(672): error C2665: 'node::Buffer::New': no
ne of the 4 overloads could convert all the argument types [C:\Projects\snom-client\node_modules\zmq\build
\zmq.vcxproj]
  C:\Projects\snom-client\node_modules\electron-rebuild\lib\headers\.node-gyp\0.31.0\src\node_buffer.h(50)
: note: could be 'v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate *,char *,size_t)'
  C:\Projects\snom-client\node_modules\electron-rebuild\lib\headers\.node-gyp\0.31.0\src\node_buffer.h(38)
: note: or       'v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate *,v8::Local<v8::String>,node::e
ncoding)'
  C:\Projects\snom-client\node_modules\zmq\node_modules\nan\nan.h(672): note: while trying to match the ar
gument list '(v8::Isolate *, const char *, uint32_t)'
C:\Projects\snom-client\node_modules\zmq\node_modules\nan\nan.h(676): error C2440: 'return': cannot conver
t from 'v8::MaybeLocal<v8::Object>' to 'v8::Local<v8::Object>' [C:\Projects\snom-client\node_modules\zmq\b
uild\zmq.vcxproj]
  C:\Projects\snom-client\node_modules\zmq\node_modules\nan\nan.h(676): note: No constructor could take th
e source type, or constructor overload resolution was ambiguous
C:\Projects\snom-client\node_modules\zmq\node_modules\nan\nan.h(683): error C2039: 'Use': is not a member
of 'node::Buffer' [C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
  C:\Projects\snom-client\node_modules\electron-rebuild\lib\headers\.node-gyp\0.31.0\src\node_buffer.h(8):
 note: see declaration of 'node::Buffer'
C:\Projects\snom-client\node_modules\zmq\node_modules\nan\nan.h(683): error C3861: 'Use': identifier not f
ound [C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(654): warning C4244: 'argument': conversion from 'int64_t' to 'const int', possible loss of
data [C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(655): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data [
C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(656): warning C4244: 'argument': conversion from 'int64_t' to 'const int', possible loss of
data [C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(657): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data [
C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(658): warning C4244: 'argument': conversion from 'int64_t' to 'const int', possible loss of
data [C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(659): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data [
C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(660): warning C4244: 'argument': conversion from 'int64_t' to 'const int', possible loss of
data [C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(661): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data [
C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(662): warning C4244: 'argument': conversion from 'int64_t' to 'const int', possible loss of
data [C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(663): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data [
C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(678): warning C4244: 'argument': conversion from 'int64_t' to 'const int', possible loss of
data [C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(679): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data [
C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(680): warning C4244: 'argument': conversion from 'int64_t' to 'const int', possible loss of
data [C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(681): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data [
C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(682): warning C4244: 'argument': conversion from 'int64_t' to 'const int', possible loss of
data [C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(683): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data [
C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(684): warning C4244: 'argument': conversion from 'int64_t' to 'const int', possible loss of
data [C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(685): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data [
C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(686): warning C4244: 'argument': conversion from 'int64_t' to 'const int', possible loss of
data [C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(687): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data [
C:\Projects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(930): error C2661: 'NanNewBufferHandle': no overloaded function takes 4 arguments [C:\Projec
ts\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(1047): warning C4244: '=': conversion from 'int64_t' to 'int', possible loss of data [C:\Pro
jects\snom-client\node_modules\zmq\build\zmq.vcxproj]
..\binding.cc(1148): warning C4244: '=': conversion from 'int64_t' to 'int', possible loss of data [C:\Pro
jects\snom-client\node_modules\zmq\build\zmq.vcxproj]

gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Projects\snom-client\node_modules\electron-rebuild\node_modu
les\npm\node_modules\node-gyp\lib\build.js:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\\Projects\\snom-client\\node_modules\\electron-rebuild\\node_modules\\npm\\nod
e_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Projects\snom-client\node_modules\zmq
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok

npm ERR! Windows_NT 6.3.9600
npm ERR! argv "node" "C:\\Projects\\snom-client\\node_modules\\electron-rebuild\\node_modules\\npm\\bin\\n
pm-cli.js" "rebuild" "--target=0.31.0" "--arch=x64"
npm ERR! node v0.12.7
npm ERR! npm  v2.14.0
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the zmq package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls zmq
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Projects\snom-client\node_modules\npm-debug.log

Process exited with code: 1
Error: Process exited with code: 1
    at ChildProcess.<anonymous> (C:\Projects\snom-client\node_modules\electron-rebuild\lib\spawn.js:53:26)

    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1015:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1087:5)

C:\Projects\snom-client>

This should not be a problem with the zmq package, because if I try to use it without the electron shell it works fine.

v1.0.1 - Mac OS X - Unknown Runtime: 'electron'

With version 1.0.1, I get the following error when rebuilding module fsevents:

Unknown Runtime: 'electron'

node-pre-gyp ERR! install error 
node-pre-gyp ERR! stack Error: Unknown Runtime: 'electron'
node-pre-gyp ERR! stack     at get_runtime_abi (.../fsevents/node_modules/node-pre-gyp/lib/util/versioning.js:60:19)
node-pre-gyp ERR! stack     at Object.module.exports.evaluate (.../fsevents/node_modules/node-pre-gyp/lib/util/versioning.js:249:19)
node-pre-gyp ERR! stack     at install (.../fsevents/node_modules/node-pre-gyp/lib/install.js:138:31)
node-pre-gyp ERR! stack     at Object.self.commands.(anonymous function) [as install] (.../fsevents/node_modules/node-pre-gyp/lib/node-pre-gyp.js:48:37)
node-pre-gyp ERR! stack     at run (.../fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp:79:30)
node-pre-gyp ERR! stack     at Object.<anonymous> (.../fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp:131:1)
node-pre-gyp ERR! stack     at Module._compile (module.js:460:26)
node-pre-gyp ERR! stack     at Object.Module._extensions..js (module.js:478:10)
node-pre-gyp ERR! stack     at Module.load (module.js:355:32)
node-pre-gyp ERR! stack     at Function.Module._load (module.js:310:12)
node-pre-gyp ERR! System Darwin 14.1.0
node-pre-gyp ERR! command "node" ".../fsevents/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd .../fsevents
node-pre-gyp ERR! node -v v0.12.7
node-pre-gyp ERR! node-pre-gyp -v v0.6.11
node-pre-gyp ERR! not ok 

rebuild fails silent on Windows 10; node 4.2.2; node-gyp 3.0.3

I tried to compile node-sass with your example code in the readme.

var version = "0.36.1";
var targetFolder = "c:/git/require";
var path = require("path");
var targetFolderNodeModulesFolder = path.join(targetFolder, 'node_modules');
var rebuild = require("electron-rebuild");


var rebuildNativeModules = function() {
    console.log("rebuildNativeModules");
    return rebuild.rebuildNativeModules(version, targetFolderNodeModulesFolder);
};

var installNodeHeaders = function (shouldBuild) {
    console.log("installNodeHeaders", shouldBuild);
    if (!shouldBuild) return true;
    return rebuild.installNodeHeaders(version).then(rebuildNativeModules);
}

var error = function  (e) {
    console.log("error");
    console.error("Building modules didn't work!");
    console.error(e);
}

rebuild.shouldRebuildNativeModules(targetFolder).then(installNodeHeaders).catch(error);}

I also tried
electron-rebuild --version 0.36.1 --module-dir c:\git\require\node_modules without success.

Gives error for sqlite3 on Ubuntu

Electron version: v0.31.2
Nodejs version: v0.12.7

Steps to reproduce:

gives following error:

> [email protected] install /home/destan/development/workspace/web/electron-boilerplate/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

Unsupported target version: 0.30.6

node-pre-gyp ERR! install error 
node-pre-gyp ERR! stack Error: Unsupported target version: 0.30.6
node-pre-gyp ERR! stack     at get_runtime_abi (/home/destan/development/workspace/web/electron-boilerplate/node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/versioning.js:140:23)
node-pre-gyp ERR! stack     at Object.module.exports.evaluate (/home/destan/development/workspace/web/electron-boilerplate/node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/versioning.js:249:19)
node-pre-gyp ERR! stack     at install (/home/destan/development/workspace/web/electron-boilerplate/node_modules/sqlite3/node_modules/node-pre-gyp/lib/install.js:138:31)
node-pre-gyp ERR! stack     at Object.self.commands.(anonymous function) [as install] (/home/destan/development/workspace/web/electron-boilerplate/node_modules/sqlite3/node_modules/node-pre-gyp/lib/node-pre-gyp.js:48:37)
node-pre-gyp ERR! stack     at run (/home/destan/development/workspace/web/electron-boilerplate/node_modules/sqlite3/node_modules/node-pre-gyp/bin/node-pre-gyp:79:30)
node-pre-gyp ERR! stack     at Object.<anonymous> (/home/destan/development/workspace/web/electron-boilerplate/node_modules/sqlite3/node_modules/node-pre-gyp/bin/node-pre-gyp:131:1)
node-pre-gyp ERR! stack     at Module._compile (module.js:460:26)
node-pre-gyp ERR! stack     at Object.Module._extensions..js (module.js:478:10)
node-pre-gyp ERR! stack     at Module.load (module.js:355:32)
node-pre-gyp ERR! stack     at Function.Module._load (module.js:310:12)
node-pre-gyp ERR! System Linux 3.13.0-62-generic
node-pre-gyp ERR! command "node" "/home/destan/development/workspace/web/electron-boilerplate/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/destan/development/workspace/web/electron-boilerplate/node_modules/sqlite3
node-pre-gyp ERR! node -v v0.12.7
node-pre-gyp ERR! node-pre-gyp -v v0.6.9
node-pre-gyp ERR! not ok 

it somehow reports the node version as 0.30.6

If I go to node_modules/node-pre-gyp/lib/util/versioning.js:53 and hardcode target_version = '0.12.7' the error vanishes.

node_modules\.bin\electron-rebuild ends without output

node_modules.bin\electron-rebuild exits fast and without output. I previously installed fibers.

.bin\electron-rebuild

c:\git\iron-node>node -v
v0.12.6

Using

  • Microsoft Windows 7 Home Premium
  • 6.1.7601 Service Pack 1 Build 7601
  • X86-based PC

"electron-prebuilt": "^0.30.0",

Node-sass bindings

I would like to make an electron app which can compile sass for you using node-sass. I packaged the app (from Linux) but once I open the app on Windows it sass the bindings are not found and I should rebuild.
Error: libsassbindings not found. Try reinstallingnode-sass``
I dropped in a precompiled file from the node-sass-binaries but I get an error about dynamic links.

Is electron-build a package which can handle this kind of problem? if not; where should I look?
I want anyone on WIN, Linux and OSX to just install my app and compile sass.

Best practice to support electron-rebuild

Hi,
I'm a maintainer of node-serialport and a bunch of my users use electron and electron-rebuild. We hadn't been supporting it as well as I'd like and with our latest beta we've upgraded nan and cleaned up our build processes. This has broth improved electron support as we work with the latest versions and made it more annoying.

According to this issue we can now run electron-rebuild but we must first remove our binary file manually. It currently resides in build/Release/serialport.node It will be there if you've built it or downloaded it via pre-gyp during install. That seems annoying. I'm a bit new to the electron ecosystem so I wanted to check with you to see if we could do something to make this easier, or provide better instructions to get it going.

Thanks!

Wrong compiled file path

How I run:

rm -rf ./node_modules/fibers/bin
./node_modules/.bin/electron-rebuild -f
ls ./node_modules/fibers/bin
# => darwin-x64-v8-4.6

When I run application I got error:

Uncaught Error: `MY_APP/node_modules/fibers/bin/darwin-x64-v8-4.7/fibers.node` is missing. Try reinstalling `node-fibers`?

If I simply copy file then it works

cp -r node_modules/fibers/bin/darwin-x64-v8-4.6 node_modules/fibers/bin/darwin-x64-v8-4.7

I use node v5.4.1

Can't rebuild nslog on windows

I'm running electron-rebuild on an Appveyor machine and cannot rebuild the nslog module. I've tried a seemingly endless combination of node, npm, python, and visual studio versions to no avail. Here's the log, any ideas?

C:\projects\my-app\app\node_modules\nslog>if not defined npm_config_node_gyp (node "C:\projects\my-app\app\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild ) 

npm WARN prefer global [email protected] should be installed with -g
gyp ERR! clean error 
gyp ERR! stack Error: EPERM, unlink 'C:\projects\my-app\app\node_modules\nslog\build\Release\nslog.node'
gyp ERR! stack     at Error (native)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\\projects\\my-app\\app\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\projects\my-app\app\node_modules\nslog
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok 

npm ERR! Windows_NT 6.3.9600
npm ERR! argv "node" "C:\\projects\\mavensmate-app\\app\\node_modules\\npm\\bin\\npm-cli.js" "rebuild" "--target=0.30.2" "--arch=ia32"
npm ERR! node v0.12.7
npm ERR! npm  v3.2.1
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the nslog package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls nslog
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\projects\my-app\app\node_modules\npm-debug.log

Process exited with code: 1

Please note npm install nslog works fine.

MSBuild unexpected CL task error

Hi,
I have no idea what's is going on, but it seems I can't rebuild electron package anymore ..
Everytime I try this command

./node_modules/.bin/electron-rebuild.cmd

I get this error :

[email protected] install C:\PROJET\lhc-electron\node_modules\lhc-se
rvice\node_modules\webblue\node_modules\bluetooth-serial-port
node-gyp configure build

C:\PROJET\lhc-electron\node_modules\lhc-service\node_modules\webblue\node_module
s\bluetooth-serial-port>if not defined npm_config_node_gyp (node "C:\PROJET\lhc-
electron\node_modules\electron-rebuild\node_modules\npm\bin\node-gyp-bin....
node_modules\node-gyp\bin\node-gyp.js" configure build ) else (node "" configur
e build )
G?n?ration des projets individuellement dans cette solution. Pour activer la g?n
?ration en parall?le, ajoutez le commutateur "/m".
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targe
ts(341,5): error MSB4018: ?chec inattendu de la t?che "CL". [C:\PROJET\lhc-elect
ron\node_modules\lhc-service\node_modules\webblue\node_modules\bluetooth-serial-
port\build\BluetoothSerialPort.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targe
ts(341,5): error MSB4018: System.TypeInitializationException: Une exception a ?t
? lev?e par l'initialiseur de type pour 'Microsoft.Build.Utilities.FileTracker'.
---> System.IO.FileNotFoundException: Le fichier sp?cifi? est introuvable. (Exc
eption de HRESULT : 0x80070002) [C:\PROJET\lhc-electron\node_modules\lhc-service
\node_modules\webblue\node_modules\bluetooth-serial-port\build\BluetoothSerialPo
rt.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targe
ts(341,5): error MSB4018: ? System.Runtime.InteropServices.Marshal.ThrowExcep
tionForHRInternal(Int32 errorCode, IntPtr errorInfo) [C:\PROJET\lhc-electron\nod
e_modules\lhc-service\node_modules\webblue\node_modules\bluetooth-serial-port\bu
ild\BluetoothSerialPort.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targe
ts(341,5): error MSB4018: ? Microsoft.Build.Shared.NativeMethodsShared.ThrowE
xceptionForErrorCode(Int32 errorCode) [C:\PROJET\lhc-electron\node_modules\lhc-s
ervice\node_modules\webblue\node_modules\bluetooth-serial-port\build\BluetoothSe
rialPort.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targe
ts(341,5): error MSB4018: ? Microsoft.Build.Shared.NativeMethodsShared.GetSho
rtFilePath(String path) [C:\PROJET\lhc-electron\node_modules\lhc-service\node_mo
dules\webblue\node_modules\bluetooth-serial-port\build\BluetoothSerialPort.vcxpr
oj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targe
ts(341,5): error MSB4018: ? Microsoft.Build.Utilities.FileTracker..cctor() [C
:\PROJET\lhc-electron\node_modules\lhc-service\node_modules\webblue\node_modules
\bluetooth-serial-port\build\BluetoothSerialPort.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targe
ts(341,5): error MSB4018: --- Fin de la trace de la pile d'exception interne
--- [C:\PROJET\lhc-electron\node_modules\lhc-service\node_modules\webblue\node_m
odules\bluetooth-serial-port\build\BluetoothSerialPort.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targe
ts(341,5): error MSB4018: ? Microsoft.Build.CPPTasks.CL.ComputeOutOfDateSourc
es() [C:\PROJET\lhc-electron\node_modules\lhc-service\node_modules\webblue\node_
modules\bluetooth-serial-port\build\BluetoothSerialPort.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targe
ts(341,5): error MSB4018: ? Microsoft.Build.CPPTasks.TrackedVCToolTask.SkipTa
skExecution() [C:\PROJET\lhc-electron\node_modules\lhc-service\node_modules\webb
lue\node_modules\bluetooth-serial-port\build\BluetoothSerialPort.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targe
ts(341,5): error MSB4018: ? Microsoft.Build.Utilities.ToolTask.Execute() [C:
PROJET\lhc-electron\node_modules\lhc-service\node_modules\webblue\node_modules\b
luetooth-serial-port\build\BluetoothSerialPort.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targe
ts(341,5): error MSB4018: ? Microsoft.Build.CPPTasks.TrackedVCToolTask.Execut
e() [C:\PROJET\lhc-electron\node_modules\lhc-service\node_modules\webblue\node_m
odules\bluetooth-serial-port\build\BluetoothSerialPort.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targe
ts(341,5): error MSB4018: ? Microsoft.Build.BackEnd.TaskExecutionHost.Microso
ft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\PROJET\lhc-electron\node_modul
es\lhc-service\node_modules\webblue\node_modules\bluetooth-serial-port\build\Blu
etoothSerialPort.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targe
ts(341,5): error MSB4018: ? Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext() [C:\PROJET\lhc-electron\node_modules\lhc-service\no
de_modules\webblue\node_modules\bluetooth-serial-port\build\BluetoothSerialPort.
vcxproj]

gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe fail
ed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\PROJET\lhc-electron\node_modules\e
lectron-rebuild\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_proces
s.js:200:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\PROJET\lhc-electron
\node_modules\electron-rebuild\node_modules\npm\node_modules\node-gyp\bin
\node-gyp.js" "configure" "build"
gyp ERR! cwd C:\PROJET\lhc-electron\node_modules\lhc-service\node_modules\webblu
e\node_modules\bluetooth-serial-port
gyp ERR! node -v v4.4.2
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok

npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\PROJET\lhc-electron\n
ode_modules\electron-rebuild\node_modules\npm\bin\npm-cli.js" "rebuild" "--
runtime=electron" "--target=0.36.12" "--arch=x64"
npm ERR! node v4.4.2
npm ERR! npm v3.8.5
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: node-gyp configure build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp conf
igure build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bluetooth-serial-port
package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp configure build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs bluetooth-serial-port
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls bluetooth-serial-port
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! C:\PROJET\lhc-electron\node_modules\npm-debug.log

Process exited with code: 1
Error: Process exited with code: 1
at ChildProcess. (C:\PROJET\lhc-electron\node_modules\electron-re
build\lib\spawn.js:55:26)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:827:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

It seems that it's a MSBuild error, I tryed to reinstall Visual Express 2013, node 4.4.2, python 2.7.11, electron etc,still the same issue stucked in ....

If you have any idea that would be great, thanks !

Unable to find electron-prebuilt's version number

Le me at the computer

Le-me PC:app Le-me$ ./node_modules/.bin/electron-rebuild 
Unable to find electron-prebuilt's version number, either install it or specify an explicit version

WTF
Y U NO
Y U NO looking for a global installed 'electron-prebuilt' module and/or define an available version in your package.json@devDependencies!!

I'm just saying
Thanks!!

edge-atom-shell not installing due to a linker error.

Hi, I can't find a better place to post this issue so I'm going with here because the error seems to be to do with the rebuild process. I hope this is a replicable issue that others may have but if it's just me being silly I'm sorry.

I'm trying to get electron and edge.js to work together. I'm using windows 10. Here are my versions of node things;

{ npm: '2.7.4',
  http_parser: '2.3',
  modules: '14',
  node: '0.12.2',
  openssl: '1.0.1m',
  uv: '1.4.2-node1',
  v8: '3.28.73',
  zlib: '1.2.8' }

If I make a new directory and run npm install edge-atom-shell I get the following output. I get the same output if I call npm install electron-prebuilt first and then npm install edge-atom-shell.

PS E:\Projects\electron4> npm install edge-atom-shell
/
> [email protected] install E:\Projects\electron4\node_modules\edge-atom-shell
> node-gyp rebuild


E:\Projects\electron4\node_modules\edge-atom-shell>if not defined npm_config_node_gyp (node "C:\Program Files (x86)\node
js\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (rebuild)
Warning: while converting VCCLCompilerTool/BasicRuntimeChecks to MSBuild, index value (-1) not in expected range [0, 4)
Warning: while converting VCCLCompilerTool/RuntimeLibrary to MSBuild, index value (-1) not in expected range [0, 4)
Warning: while converting VCCLCompilerTool/RuntimeTypeInfo to MSBuild, expected bool; got '-1'
Warning: while converting VCCLCompilerTool/RuntimeLibrary to MSBuild, index value (-1) not in expected range [0, 4)
Warning: while converting VCCLCompilerTool/RuntimeTypeInfo to MSBuild, expected bool; got '-1'
Warning: while converting VCCLCompilerTool/BasicRuntimeChecks to MSBuild, index value (-1) not in expected range [0, 4)
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  edge.cpp
  utils.cpp
  clrfunc.cpp
  clrfuncinvokecontext.cpp
  nodejsfunc.cpp
  nodejsfuncinvokecontext.cpp
  persistentdisposecontext.cpp
  clrfuncreflectionwrap.cpp
  v8synchronizationcontext.cpp
  clractioncontext.cpp
LINK : fatal error LNK1104: cannot open file 'MSVCMRT.lib' [E:\Projects\electron4\node_modules\edge-atom-shell\build\edge.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd E:\Projects\electron4\node_modules\edge-atom-shell
gyp ERR! node -v v0.12.2
gyp ERR! node-gyp -v v1.0.3
gyp ERR! not ok
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "edge-atom-shell"
npm ERR! node v0.12.2
npm ERR! npm  v2.7.4
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the edge-atom-shell package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
LINK : fatal error LNK1104: cannot open file 'MSVCMRT.lib' 
npm ERR! You can get their info via:
npm ERR!     npm owner ls edge-atom-shell
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     E:\Projects\electron4\npm-debug.log

The important thing seems to be that I'm getting a linker error LINK : fatal error LNK1104: cannot open file 'MSVCMRT.lib' [E:\Projects\electron4\node_modules\edge-atom-shell\build\edge.vcxproj] What do I need to do to get this to work?

Here is npm-debug.log. It's pretty much meaningless to me so I've probably missed something trivial. Is there something I need to globally install before this will work?

DLL initialisation routine failed in Electron on Windows 10

I have tried to implement my own native module with electron, but im getting the following js error inside my console:"Uncaught Error:DLL initialisation routine failed C:.../node". I used npm install NameOfMyModuleto install it. My main.js looks like this: var NameOfMyModule = require('NameOfMyModule');
I run electron-rebuild.cmd after calling npm install.

Edit: when im using nodejs the module works fine

Promisify doesn't encapsulate ncp properly in node-pre-gyp-fix

When using electron-rebuild to rebuild node-serialport module the output directory (e.g. node_modules\serialport\build\Release\node-v47-win32-ia32) would alternate between empty and correctly containing the .node file.

I did a bit of debugging and it seems to be caused by interaction between ncp and the main promise chain. When ncp.js tries to copy into a directory with an existing .node file it will remove the file and then copy it in, which in turn calls fs.unlink() with a callback. However, the await in node-pre-gyp-fix doesn't know about this async call and fires immediately, causing the process to exit. On my machine, it'd exit after the file has been deleted but before the new file is copied in, which would give me an empty directory. Removing process.exit() fixes this bug as it allows the fs.unlink() callback to finish.

spawn dist/electron.exe ENOENT

win10 + 64
node.js 5.1.1 + 32

  "dependencies": {
    "ffi": "^2.0.0"
  },
  "devDependencies": {
    "electron-prebuilt": "^0.36.0",
    "electron-rebuild": "^1.0.2"
  }
  • exec
.\node_modules\.bin\electron-rebuild.cmd
  • error info
spawn dist/electron.exe ENOENT
Error: spawn dist/electron.exe ENOENT
    at exports._errnoException (util.js:856:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
    at onErrorNT (internal/child_process.js:344:16)
    at doNTCallback2 (node.js:452:9)
    at process._tickCallback (node.js:366:17)

node_modules\electron-prebuilt\dist\electron.exe is exist

Rebuilding native modules directory naming issue

When rebuilding with the serialport module, it names the final directory as

electron-v0.34.1-darwin-x64

However, when ran with the executable, it is looking for

node-v46-darwin-x64

It seems like in main.js, the directory name and electron versioning is mixed.

ENOENT :(

Getting this error when running v0.2.5.

$ electron-rebuild                                                        
ENOENT: no such file or directory, stat '/Users/mikeal/git/electerm/node_modules/electron-rebuild/lib/headers/.node-gyp/0.31.0/common.gypi'
Error: ENOENT: no such file or directory, stat '/Users/mikeal/git/electerm/node_modules/electron-rebuild/lib/headers/.node-gyp/0.31.0/common.gypi'
    at Error (native)

I'm on Mac OS X, El Capitan 10.11 Beta (15A263e)

electron-rebuild doesn't seem to do anything on windows :(

Hey Paul!

Trying to get node-ffi working with electron on windows. Super simple project.

Steps I took:

npm install ffi --save
npm install electron-rebuild

I then run ./node_modules/.bin/electron-rebuild
And.... nothing happens. Back to the shell. No output or anything and it's super fast.

When trying to run my electron app I get the 'module did not self-register' error.

Hoping you have some tips for me!
Thanks,

Matt

Unsupported target version: 0.34.0

Upon rebuilding npm serialport using electron-rebuild, im getting the error: "Unsupported target version: 0.34.0":

node-pre-gyp ERR! install error
node-pre-gyp ERR! stack Error: Unsupported target version: 0.34.0
node-pre-gyp ERR! stack at get_node_abi (/home/domingo/dev/hookninja/node_modules/serialport/node_modules/node-pre-gyp/lib/util/versioning.js:27:19)
node-pre-gyp ERR! stack at Object.module.exports.evaluate (/home/domingo/dev/hookninja/node_modules/serialport/node_modules/node-pre-gyp/lib/util/versioning.js:133:21)
node-pre-gyp ERR! stack at install (/home/domingo/dev/hookninja/node_modules/serialport/node_modules/node-pre-gyp/lib/install.js:134:35)
node-pre-gyp ERR! stack at Object.self.commands.(anonymous function) as install
node-pre-gyp ERR! stack at run (/home/domingo/dev/hookninja/node_modules/serialport/node_modules/node-pre-gyp/bin/node-pre-gyp:77:30)
node-pre-gyp ERR! stack at Object. (/home/domingo/dev/hookninja/node_modules/serialport/node_modules/node-pre-gyp/bin/node-pre-gyp:130:1)
node-pre-gyp ERR! stack at Module._compile (module.js:456:26)
node-pre-gyp ERR! stack at Object.Module._extensions..js (module.js:474:10)
node-pre-gyp ERR! stack at Module.load (module.js:356:32)
node-pre-gyp ERR! stack at Function.Module._load (module.js:312:12)
node-pre-gyp ERR! System Linux 3.19.0-25-generic
node-pre-gyp ERR! command "node" "/home/domingo/dev/hookninja/node_modules/serialport/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/domingo/dev/hookninja/node_modules/serialport
node-pre-gyp ERR! node -v v0.10.37
node-pre-gyp ERR! node-pre-gyp -v v0.5.19
node-pre-gyp ERR! not ok
Unsupported target version: 0.34.0

npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the serialport package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR! npm owner ls serialport
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.19.0-25-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "i" "serialport"
npm ERR! cwd /home/domingo/dev/hookninja
npm ERR! node -v v0.10.37
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0

SyntaxError: Unexpected token case

Running node .\node_modules\.bin\electron-rebuild, on Windows 10 x64 with node 4.2.1 installed (and got the same error with 4.1.2), gives:

case `uname` in
^^^^

SyntaxError: Unexpected token case
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:413:25)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:475:10)
    at startup (node.js:118:18)
    at node.js:952:3

Electron rebuild failing strangely on Appveyor

Error

Error: ENOENT: no such file or directory, open 'C:\projects\google-play-music-desktop-player-unofficial\node_modules\undefined'

For some reason it is attempted to rebuild a module with the name undefined. It doesn't do this locally or on any other windows machine I have available. Looking for any suggestions as to what is going on here.

Node: 4.4.x
NPM: 3.x.x

Full Stack Trace

C:\projects\google-play-music-desktop-player-unofficial\node_modules>.bin\electron-rebuild.cmd -f 

gyp WARN install got an error, rolling back install
gyp ERR! install error 
gyp ERR! stack Error: ENOENT: no such file or directory, open 'C:\projects\google-play-music-desktop-player-unofficial\node_modules\undefined'
gyp ERR! stack     at Error (native)
gyp ERR! stack     at Object.fs.openSync (fs.js:549:18)
gyp ERR! stack     at Object.fs.readFileSync (fs.js:397:15)
gyp ERR! stack     at readCAFile (C:\projects\google-play-music-desktop-player-unofficial\node_modules\npm\node_modules\node-gyp\lib\install.js:466:15)
gyp ERR! stack     at download (C:\projects\google-play-music-desktop-player-unofficial\node_modules\npm\node_modules\node-gyp\lib\install.js:438:22)
gyp ERR! stack     at C:\projects\google-play-music-desktop-player-unofficial\node_modules\npm\node_modules\node-gyp\lib\install.js:185:19
gyp ERR! stack     at C:\projects\google-play-music-desktop-player-unofficial\node_modules\npm\node_modules\mkdirp\index.js:30:20
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\projects\\google-play-music-desktop-player-unofficial\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "install" "--target=0.37.8" "--arch=ia32" "--dist-url=https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist"
gyp ERR! cwd C:\projects\google-play-music-desktop-player-unofficial\node_modules
gyp ERR! node -v v4.4.1
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok 


Process exited with code: 1
Error: Process exited with code: 1
    at ChildProcess.<anonymous> (C:\projects\google-play-music-desktop-player-unofficial\node_modules\electron-rebuild\lib\spawn.js:55:26)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at maybeClose (internal/child_process.js:827:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

Rebuild failed

Makes electron-rebuild source installable as a dependency

On windows I can only install published release of electron-rebuild.
If I try to install from source :

> npm install electronjs/electron-rebuild --loglevel=info
...
npm info lifecycle [email protected]~preinstall: [email protected]
npm info lifecycle [email protected]~preinstall: [email protected]
npm info lifecycle [email protected]~preinstall: [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm WARN ENOENT ENOENT: no such file or directory, open 'node_modules\npm-debug.log\package.json'
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "electronjs/electron-rebuild" "--loglevel=info"
npm ERR! node v5.3.0
npm ERR! npm  v3.3.12
npm ERR! path node_modules\electron-rebuild\lib\cli.js
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall chmod

npm ERR! enoent ENOENT: no such file or directory, chmod 'node_modules\electron-rebuild\lib\cli.js'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

This an issue because it makes it harder to test before publishing AND it prevent to install a Fork (or the HEAD) without publishing it nor using wierd hacks.

We currently have a usecase, were some blocking issue have been reported several weeks ago, pull requests were made but the problem is not solved because it not have been merge and or published yet. As we cannot install simply a fork, we're blocked until changes are all merged AND published.

The solution could be to add a preinstall script that check the existence of compiled files lib/*.js.
If they are missing it should install dev dependencies and compile source js.

error, Unexpected token case. (windows)

I am trying to use electron rebuild on windows (10 , x64), running node 4.1.0. But when I run the command specified in the documentation

./node_modules/.bin/electron-rebuild

I get the following error

F:\app\node_modules.bin\electron-rebuild:4
case uname in
^^^^

SyntaxError: Unexpected token case
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:413:25)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
at startup (node.js:117:18)
at node.js:951:3

Published version of electron-rebuild isn't compatible with the latest babel-core

The current published version of electron-rebuild (0.2.1) isn't compatible with the latest releases of babel-core. This seems to be related to changes in regenerator babel/babel#1685

Recompiling the source files and publishing a new version should fix the problem. You can reproduce this issue by downloading the released tarball and running the tests in this repo (but not regenerating the source files) against [email protected] (a dependency of babel-core)

Here's the output from running the test (I removed the part where it regenerates the lib files, so it can just used the published version):

% npm test

> [email protected] test /Users/rich/src/electron-rebuild/dist/package
> npm run compile && mocha test-dist/*


> [email protected] compile /Users/rich/src/electron-rebuild/dist/package
> babel --stage 0 -d test-dist/ test/

test/main.js -> test-dist/main.js
test/promisify.js -> test-dist/promisify.js
test/spawn.js -> test-dist/spawn.js
test/support.js -> test-dist/support.js


  installNodeHeaders
    1) installs node headers for 0.25.2

  rebuildNativeModules
    2) Rebuilds native modules against 0.22.0

  shouldRebuildNativeModules
    ✓ should always return true most of the time maybe

  promisify
    ✓ should handle fs.stat
    ✓ should map all of fs

  spawn
    ✓ should work with ls
    ✓ should fail when the path is completely bogus


  5 passing (62ms)
  2 failing

  1) installNodeHeaders installs node headers for 0.25.2:
     ENOENT, stat '/Users/rich/src/electron-rebuild/dist/package/test-dist/testheaders/.node-gyp/0.25.2/common.gypi'
  Error: ENOENT, stat 'test-dist/testheaders/.node-gyp/0.25.2/common.gypi'

  2) rebuildNativeModules Rebuilds native modules against 0.22.0:
     ENOENT, stat '/Users/rich/src/electron-rebuild/dist/package/test-dist/testheaders/.node-gyp/0.22.0/common.gypi'
  Error: ENOENT, stat 'test-dist/testheaders/.node-gyp/0.22.0/common.gypi'

node-gyp error when running rebuild on node usb

i need to run a node-gyp rebuild on node usb as electron rebuild does not work because of node-pre-gyp, i have run the following guys advice on mac osx and it works perfectly, but windows it fails (running windows 10 with vs 2015 community desktop).

gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\matthewhardern\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\matthewhardern\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--target=0.36.2" "--dist-url=https://atom.io/download/atom-shell"
gyp ERR! cwd C:\electron-test\node_modules\usb
gyp ERR! node -v v4.2.3
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok

following this https://discuss.atom.io/t/use-node-usb-inside-electron/16748/2

third comment down.

any help would be great.

Verbose output option

Depending on what packages it has to deal with, electron-rebuild sometimes takes a good long while; @paulcbetts would you be open adding a 'verbose' CLI option that shows that it's doing?

how can I specify the disturl to download headers

I am in China,you know,a place where we cannot connect to the internet convenient.I cannot connect to aws,so I have to use a mirror to download the header.but electron-rebuild --help doesn't tell me how to specify a disturl

Rebuild a single module

I'd love for this to be able to rebuild a single node_module (in case it has been updated etc). I can add the functionality, but which flag would it go under? -p (for package)?

target version not detected on rebuild

hi all:

when electron-rebuild goes to rebuild assets, it complains that target version is missing. per this discussion, it should be populated in the latest version of electron-rebuild.

E.g.:

cdieringer@Snapper-osx:~/node/coinstac$ ll node_modules/ | grep electron
drwxr-xr-x  15 cdieringer  staff   510 Oct 12 13:36 electron-prebuilt/
drwxr-xr-x  10 cdieringer  staff   340 Oct 12 14:03 electron-rebuild/
cdieringer@Snapper-osx:~/node/coinstac$ cat package.json | grep electron
    "electron-prebuilt": "^0.33.7",
    "electron-rebuild": "^1.0.1",

however, it still yields the following, against expectation:

...
> [email protected] install /Users/cdieringer/node/coinstac/node_modules/babel/node_modules/chokidar/node_modules/fsevents
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! install error
node-pre-gyp ERR! stack Error: Empty target version is not supported if electron is the target.

Doesn't build on windows: without error

I'm using the native printer module from npm to access a simple printer.

The usual "recompile all modules" does not work for me (cli and own script), it simply prints nothing.

I still manage to rebuild the module with the newest versions of nodejs, electron and node-gyp:

gastroprinter\node_modules\printer> node-gyp rebuild --target=0.36.7 --arch=ia32 --dist-url=https://atom.io/download/atom-shell

Please add some console printout if no module has been recompiled (and it didn't work) and investigate why printer can only be recompiled manually!

doesn't work

npm install sqlite3 --save which costs around 3 minutes.
then I run ./node_modules/.bin/electron-rebuild, command finished in less than 1 second and there's none output information.

specifying nodeModulesPath has no effect

regardless of what is specified as the nodeModulesPath when invoking rebuildNativeModules, the node_modules under the current directory is used. looking at the code in main.js this argument appears to be unused.

Canary file 'common.gypi' doesn't exist

Getting this error trying to rebuild my dependencies (npm install && electron-rebuild with "./node_modules/.bin" in path):

Error: Canary file 'common.gypi' doesn't exist
    at checkForInstalledHeaders$ (/Users/natevw/…/my-app/node_modules/electron-rebuild/lib/main.js:58:15)
    at tryCatch (/Users/natevw/Desktop/…/my-app/node_modules/electron-rebuild/node_modules/babel-core/node_modules/regenerator/runtime.js:61:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/natevw/…/my-app/node_modules/electron-rebuild/node_modules/babel-core/node_modules/regenerator/runtime.js:305:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Users/natevw/…/my-app/node_modules/electron-rebuild/node_modules/babel-core/node_modules/regenerator/runtime.js:94:21)
    at invoke (/Users/natevw/…/my-app/node_modules/node_modules/electron-rebuild/node_modules/babel-core/node_modules/regenerator/runtime.js:132:37)
    at /Users/natevw/…/my-app/node_modules/node_modules/electron-rebuild/node_modules/babel-core/node_modules/regenerator/runtime.js:166:18
    at run (/Users/natevw/…/my-app/node_modules/node_modules/electron-rebuild/node_modules/babel-core/node_modules/core-js/modules/es6.promise.js:89:39)
    at /Users/natevw/…/my-app/node_modules/node_modules/electron-rebuild/node_modules/babel-core/node_modules/core-js/modules/es6.promise.js:100:28
    at process._tickCallback (node.js:355:11)

My package.json is:

{
  "name": "some-app",
  "private": true,
  "version": "0.0.0",
  "description": "Some App",
  "repository": {
    "type": "git",
    "url": "…"
  },
  "main": "backend.js",
  "dependencies": {
    "d3": "^3.4.11",
    "fermata": "git://github.com/natevw/fermata.git#upcoming",
    "keytar": "^2.0.3",
    "node-hid": "https://github.com/natevw/node-hid/releases/download/test-node-12/node-hid-0.3.2.tgz"
  },
  "devDependencies": {
    "electron-prebuilt": "^0.26.0",
    "electron-rebuild": "^0.1.4"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "while :; do ~/Downloads/atom-shell-v0.17.2-darwin-x64/Atom.app/Contents/MacOS/Atom .; done"
  },
  "author": "Nathan Vander Wilt"
}

Rebuild exits fine / cannot find module 'express'

I tried taking the "easy way" to include express into my electron project. Sadly it's still throwing me a Cannot find module 'express'.

What I did:

  1. npm install --save-dev electron-rebuild
  2. npm install --save-dev electron-prebuilt
  3. npm install --save express
  4. .\node_modules\.bin\electron-rebuild.cmd (yes, I'm on Windows)
  5. Run my project (var express = require('express');)

No errors, filemtime updated, no idea what I'm doing wrong. Any clue?

No license

Could you include a license file for this repo? If anyone is to use this in a professional setting they are on very shaky legal ground without one.

Silent error breaking installNodeHeaders

The published npm package v0.2.2 doesn't seem to include the fix in Pull Request #7 which I believe is causing installNodeHeaders to be broken for me. I'm having trouble catching any errors. Seems to silently fail.
I also can't get npm to successfully install straight from Github to give the latest commits a try.

Question re: Electron app distribution process

If I'm including a node module in my Electron app that requires native bindings (keytar), do I need to include electron-rebuild as well and rebuild programmatically anytime the app is installed/updated on a user's local machine or is this a one-time process during build, per platform?

Failed to check Electron's module version number

On Windows:

> .\node_modules\.bin\electron-rebuild.cmd
46
Failed to check Electron's module version number: [...]

electron-prebuilt and electron-rebuild were both installed with npm install --save-dev:

"devDependencies": {
    "electron-prebuilt": "^0.35.2",
    "electron-rebuild": "^1.0.2"
}

mention require-rebuild

I wrote a module for this that takes a different approach: it patches require() to recompile node modules on the fly if they have been built against a different api. More magic, but one step less to worry about.

https://github.com/juliangruber/require-rebuild

Might be nice to mention in the README. Feel free to just close and ignore if you think otherwise.

"Unable to find electron-prebuilt's version number"

As described in the Electron documentation and this module's README, I simply installed via npm install --save-dev electron-rebuild and attempted to use via ./node_modules/.bin/electron-rebuild.

This only resulted in an error message:

Unable to find electron-prebuilt's version number, either install it or specify an explicit version

usage confusion

I have a package that is listed as not compatible with atom under linux (the warning does not appear on osx, which is weird, but another issue):

Atom Mermaid 0.1.1
Listed below are the incompatible native modules that this package depends on.

[email protected]
Error message: Module did not self-register.

So I try to fix this with:

$ cd ~/.atom/packages/atom-mermaid
$ npm install --save-dev electron-rebuild
$ ./node_modules/.bin/electron-rebuild -v 0.22.3 -m node_modules/
Couldn't find electron-prebuilt and no --node-module-version parameter set, always rebuilding

This message is kind of confusing. What node module version is it talking about? atom-mermaid's? contextify's?
It still does something, but the incompatibility message did not disappear.

Trying this

$ ./node_modules/.bin/electron-rebuild -v 0.22.3 -m node_modules/ -n 0.1.1 # atom-mermaids version

It still does something, but the incompatibility message did not disappear.

$ ./node_modules/.bin/electron-rebuild -v 0.22.3 -m node_modules/d3/node_modules/jsdom/node_modules/contextify/ -n 0.1.14

The incompatibility message did not disappear.

Am I missing anything? Choosing -m and -n is complete guess work for me 😕

Cannot rebuild fsevents

When I have npm modules such as webpack or babel, I cannot run electron-rebuild successfully because it failed on rebuilding fsevents, which is a dependency of the other npm modules.

The way I see it, modules such as fsevents, or webpack do not need rebuild, because they are usually devDependencies. So I think there should be an option to ignore some npm modules.

Unsupported target version: 0.24.0 on MacOS

So far I haven't been able to get this to work. I've tried with electron 24 and the latest, and also iojs1.8.0, 2.0 and a slew of node versions. Am I doing something wrong?

~/Projects/robotnik (ElectronAndChrome ✘)✹✭ ᐅ node_modules/.bin/electron-rebuild 

> [email protected] install /Users/pawel/Projects/robotnik/node_modules/johnny-five/node_modules/serialport
> node-pre-gyp install --fallback-to-build

Unsupported target version: 0.24.0

node-pre-gyp ERR! install error 
node-pre-gyp ERR! stack Error: Unsupported target version: 0.24.0
node-pre-gyp ERR! stack     at get_node_abi (/Users/pawel/Projects/robotnik/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/lib/util/versioning.js:27:19)
node-pre-gyp ERR! stack     at Object.module.exports.evaluate (/Users/pawel/Projects/robotnik/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/lib/util/versioning.js:133:21)
node-pre-gyp ERR! stack     at install (/Users/pawel/Projects/robotnik/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/lib/install.js:134:35)
node-pre-gyp ERR! stack     at Object.self.commands.(anonymous function) [as install] (/Users/pawel/Projects/robotnik/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/lib/node-pre-gyp.js:48:37)
node-pre-gyp ERR! stack     at run (/Users/pawel/Projects/robotnik/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/bin/node-pre-gyp:77:30)
node-pre-gyp ERR! stack     at Object.<anonymous> (/Users/pawel/Projects/robotnik/node_modules/johnny-five/node_modules/serialport/node_modules/node-pre-gyp/bin/node-pre-gyp:130:1)
node-pre-gyp ERR! stack     at Module._compile (module.js:460:26)
node-pre-gyp ERR! stack     at Object.Module._extensions..js (module.js:478:10)
node-pre-gyp ERR! stack     at Module.load (module.js:355:32)
node-pre-gyp ERR! stack     at Function.Module._load (module.js:310:12)
node-pre-gyp ERR! System Darwin 14.3.0
node-pre-gyp ERR! command "node" "/Users/pawel/Projects/robotnik/node_modules/johnny-five/node_modules/serialport/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/pawel/Projects/robotnik/node_modules/johnny-five/node_modules/serialport
node-pre-gyp ERR! node -v v0.12.2
node-pre-gyp ERR! node-pre-gyp -v v0.5.19
node-pre-gyp ERR! not ok 

npm ERR! Darwin 14.3.0
npm ERR! argv "node" "/Users/pawel/Projects/robotnik/node_modules/electron-rebuild/node_modules/npm/bin/npm-cli.js" "rebuild" "--target=0.24.0" "--arch=x64"
npm ERR! node v0.12.2
npm ERR! npm  v2.9.0
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! This is most likely a problem with the serialport package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR!     npm owner ls serialport
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/pawel/Projects/robotnik/npm-debug.log

Process exited with code: 1
Error: Process exited with code: 1
    at ChildProcess.<anonymous> (/Users/pawel/Projects/robotnik/node_modules/electron-rebuild/lib/spawn.js:53:26)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1015:16)
    at Socket.<anonymous> (child_process.js:1183:11)
    at Socket.emit (events.js:107:17)
    at Pipe.close (net.js:485:12)

No such file ..\src\nslog_win.cc for node_modules\nslog\build\nslog.vcxproj

I'm at my wits end. Long night of trying Microsoft to work. First I had to manually find cl.exe in one of my Visual Studio installs and now this:
c:\users\wojtek\documents\workspace\node\tryble\node_modules\electron-rebuild\node_modules\nslog\src\nslog.h(4): fatal error C1083: Cannot open include file: 'string': No such file or directory (..\src\main.cc) [C:\Users\Wojtek\Document
s\workspace\node\tryble\node_modules\electron-rebuild\node_modules\nslog\build\nslog.vcxproj]
c:\users\wojtek\documents\workspace\node\tryble\node_modules\electron-rebuild\node_modules\nslog\src\nslog.h(4): fatal error C1083: Cannot open include file: 'string': No such file or directory (..\src\nslog_win.cc) [C:\Users\Wojtek\Doc
uments\workspace\node\tryble\node_modules\electron-rebuild\node_modules\nslog\build\nslog.vcxproj]

God, I hate Microsoft, I'm sure you do too. Any thoughts on this one? I swear I tried everything under the sun here. I cannot install electron-rebuild to save my life.

As an aside: Is there really no easier way? Isn't there an io.js or node version that is the same as electron? Am I missing something obvious? I can't seem to find any local (disk, not IndexDB) storage that is not native (sqlite and now trying leveldb).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.