Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: None of the binaries loaded successfully. Is your node version either latest 4, 5, 6, 7, 8 or 9 ? #80

Closed
azuri-gm opened this issue Jul 30, 2018 · 25 comments

Comments

@azuri-gm
Copy link

azuri-gm commented Jul 30, 2018

Hi,

Currently I'm trying to connect to a SQL Server DB using Active Directory credentials while running an azure function (node version 6.11.2) using msnodesqlv8 and mssql. This is a little test code I made for trying the connection:

const sql = require('mssql/msnodesqlv8');

const connectionString = `Server=${serverName},${portNumber};Initial Catalog=${databaseName};Authentication= Active Directory Password;Persist Security Info=False;User ID=${ADUserName};Password=${ADUserPassword};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;’`;

const pool = new sql.ConnectionPool(connectionString);
pool.connect(err => {
    if (!err) console.log('connection was successful');
    console.log(err);
});

And whenever I try connecting I'm getting the folowing error back:

"Exception while executing function: Functions.mssqlTest -> One or more errors occurred. -> Error: None of the binaries loaded successfully. Is your node version either latest 4, 5, 6, 7, 8 or 9 ?\n at failIfNoBinaryExported"

Is there something I'm missing?.

Thanks for your help!

@TimelordUK
Copy link
Owner

Is it possible in bootstrap .js to add a debug line to see if it is even attempting to load libs. Inside loop below. I assume you are running this on the cloud ? You can get code to work locally on your local machine ? Also out of interest if you just run the sample JavaScript do you see same error or does the database report an error in which case the driver has loaded.

files.forEach(function (file) {
if (noBinaryExported()) {
attemptToExportBinary(file)
}
})

@TimelordUK
Copy link
Owner

One possibility is the library cannot load as the visual studio cpp 2017 runtime is not installed. I do run the unit tests on app veyor where library does run. If it is a dll failure this would be tricky to find without access to run diagnostics on target.

@tusharacc
Copy link

tusharacc commented Oct 8, 2018

I am facing the similar issue
Context: I am building an electron app, which is querying a sql server (remote server) to get the data from table. I am using mssqlnodev8.

Error: When I start the electron app using npm start, I get the below error -

Uncaught Error: None of the binaries loaded successfully. Is your node version either latest 4, 5, 6, 7, 8 or 9 ? at failIfNoBinaryExported (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:63) at Object.liveLoad (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:50) at Object. (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:79) at Object. (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:81) at Module._compile (internal/modules/cjs/loader.js:711) at Object.Module._extensions..js (internal/modules/cjs/loader.js:722) at Module.load (internal/modules/cjs/loader.js:620) at tryModuleLoad (internal/modules/cjs/loader.js:559) at Function.Module._load (internal/modules/cjs/loader.js:551) at Module.require (internal/modules/cjs/loader.js:658)

Additional information about electron app - I am using bootstrap for my UI. As per electron faq site, I have the below code in my entry html file

<script>
  window.nodeRequire = require;
  delete window.require;
  delete window.exports;
  delete window.module;
</script>  

All the modules except electron (index.js - entry point) is imported with

nodeRequire

Analysis done till now -

The javascript logic to connect to database and fetch records are in separate js file. When I execute the file with 'node file.js', it works perfectly fine and returns records.
The node version is v9.8.0. Electron version is 3.0.2
I analyzed bootstrap.js file in node_modules\msnodesqlv8\lib\bootstrap.js, line number 63. It traced to below code

var files = require('fs').readdirSync(binaryDir)
I changed that too nodeRequire, but it didnt work.

I have checked similar issues in github but none of the resolutions helped.

UPDATED I analyzed the bootstrap.js in msnodesqlv8. These are the different error messages

Error while exporting binary Error: ?\C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bin\sqlserverv8.electron.v2.0.4.ia32.node is not a valid Win32 application. ?\C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bin\sqlserverv8.electron.v2.0.4.ia32.node at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20) at Object.Module._extensions..node (internal/modules/cjs/loader.js:740) at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:166:20) at Module.load (internal/modules/cjs/loader.js:620) at tryModuleLoad (internal/modules/cjs/loader.js:559) at Function.Module._load (internal/modules/cjs/loader.js:551) at Module.require (internal/modules/cjs/loader.js:658) at require (internal/modules/cjs/helpers.js:20) at attemptToExportBinary (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:58) at C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:48

Error while exporting binary Error: The module '?\C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bin\sqlserverv8.electron.v2.0.4.x64.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 57. This version of Node.js requires NODE_MODULE_VERSION 64. 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:166:20) at Object.Module._extensions..node (internal/modules/cjs/loader.js:740) at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:166:20) at Module.load (internal/modules/cjs/loader.js:620) at tryModuleLoad (internal/modules/cjs/loader.js:559) at Function.Module._load (internal/modules/cjs/loader.js:551) at Module.require (internal/modules/cjs/loader.js:658) at require (internal/modules/cjs/helpers.js:20) at attemptToExportBinary (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:58) at C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:48

Error while exporting binary Error: ?\C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bin\sqlserverv8.node.v10.8.0.ia32.node is not a valid Win32 application. ?\C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bin\sqlserverv8.node.v10.8.0.ia32.node at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20) at Object.Module._extensions..node (internal/modules/cjs/loader.js:740) at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:166:20) at Module.load (internal/modules/cjs/loader.js:620) at tryModuleLoad (internal/modules/cjs/loader.js:559) at Function.Module._load (internal/modules/cjs/loader.js:551) at Module.require (internal/modules/cjs/loader.js:658) at require (internal/modules/cjs/helpers.js:20) at attemptToExportBinary (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:58) at C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:48

@TimelordUK
Copy link
Owner

TimelordUK commented Oct 8, 2018 via email

@TimelordUK
Copy link
Owner

can you try again with latest version, I have not had time to look at this in detail but I have added electron vs 3 binaries which may do the trick. If this doesnt work I will reproduce issue you are seeing.

try 0.6.9 from npm.

@tusharacc
Copy link

@TimelordUK , thanks for your support. version 0.6.9 did the trick. I am no longer getting the same error in console while loading the electronjs app.

@Durzo84
Copy link

Durzo84 commented Feb 10, 2019

This is an FYI for anyone that has this issue and struggles like I did to find the solution...
This issue arises because each release of electron has its own node modules version that may be different to the version of node you have installed. EG you might have node 10.11 installed locally, but electron 4.0.4 uses node v10.15. So if you try to rebuild the binaries of your dependencies, you will still get an error due to a node_modules_version mismatch.

This issue is fixed by installing electron-rebuild, and running it with the flags -p -t "dev,prod,optional".
This will force a rebuild of msnodesqlv8 with the correct bindings for the node version electron is using.

You then need to copy the resulting msnodesqlv8.node file into the lib/bin folder

@tusharacc
Copy link

I am facing the same issue again.

electron version= 4.0.7
node version = 10.11.0
msnodesqlv8 version = 0.6. 12 (the comment mentions that it works with electron 4 and node version 10)

@Durzo84 , I installed electron-rebuild and executed the following command , npm rebuild

"rebuild": "electron-rebuild -p -t msnodesqlv8"

However I dont see any msnodesqlv8.node in node_modules folder. What am I missing?

@TimelordUK
Copy link
Owner

TimelordUK commented Mar 6, 2019 via email

@tusharacc
Copy link

tusharacc commented Mar 6, 2019

@TimelordUK , I have node 10.11 and electron 4.0.7 installed on my system. If you are looking for something else, please let me know.

So I guess electron binary should be named after both version of node and electron

--> I dont understand this, where do I check this?

@tusharacc
Copy link

@TimelordUK , I think I understand a bit now. When I checked the bin folder, it had binaries for electron 4.0.1 and node 10.13.0. I uninstalled electron, and installed 4.0.1 and upgraded node to 10.13.0. It worked.

However I have a silly question, is there a way, we can generate the binaries for msnodesqlv8?

@mattdaisley
Copy link

Thanks @tusharacc for helping me make sense of this too.
@TimelordUK I've upgraded to node 10.15.1 and am now unable to build. So I'd echo the "silly question" form tusharacc.

@Durzo84
Copy link

Durzo84 commented Mar 7, 2019

I am facing the same issue again.

electron version= 4.0.7
node version = 10.11.0
msnodesqlv8 version = 0.6. 12 (the comment mentions that it works with electron 4 and node version 10)

@Durzo84 , I installed electron-rebuild and executed the following command , npm rebuild

"rebuild": "electron-rebuild -p -t msnodesqlv8"

However I dont see any msnodesqlv8.node in node_modules folder. What am I missing?

Hi,

Sorry I should have been more detailed with my response.
In order for electron-rebuild to build the binaries for the version of electron you are using, you need to rename the file bindingdotgyp.old to binding.gyp (found in ./node_modules/msnodesqlv8/). binding.gyp is the file electron-rebuild uses to build the binaries. If it does not find this file it will not initiate the rebuild.

step 1) rename ./node_modules/msnodesqlv8/bindingdotgyp.old to ./node_modules/msnodesqlv8/binding.gyp

step 2) run electron rebuild (I now use this command from root dir: "cd ./node_modules/.bin/ && electron-rebuild -f -w msnodesqlv8 --module-dir ..\..\"). This tells electron-rebuild to rebuild the msnodesqlv8 module only, and that the node_modules directory it should look in is 2 levels up from the electron-rebuild modules folder

step 3) move the resulting .node file from
'./node_modules/msnodesqlv8/bin/win32-x64-69/msnodesqlv8.node'
to
'./node_modules/msnodesqlv8/lib/bin/msnodesqlv8.node'

I have a gulp task that does all this for me, I can attach the code if you like.

@Durzo84
Copy link

Durzo84 commented Mar 7, 2019

I should also add that because you are renaming and adding/moving files, the hash value in package-lock.json for msnodesqlv8 will no longer match what is actually in the modules folder, and whenever you add/remove/update packages, npm will reinstall whichever version of msnodesqlv8 you had installed, which will remove the new bindings file you have created, and restore the module folder to it's original state. There is probably a way to stop this from happening, but I haven't really looked into how, I just have a gulp task that does the above steps for me on postinstall.

@mattdaisley
Copy link

Thank you @Durzo84 for the information! Your steps solved my issue. Here are my package.json scripts for accomplishing these tasks after install:

"scripts": {
    "copybinding": "copy .\\node_modules\\msnodesqlv8\\bindingdotgyp.old .\\node_modules\\msnodesqlv8\\binding.gyp",
    "rebuild": "cd .\\node_modules\\.bin\\ && electron-rebuild -f -w msnodesqlv8 --module-dir ..\\..\\",
    "movenode": "move .\\node_modules\\msnodesqlv8\\bin\\win32-x64-69\\msnodesqlv8.node .\\node_modules\\msnodesqlv8\\lib\\bin\\msnodesqlv8.node",
    "postinstall": "npm run copybinding && npm run rebuild && npm run movenode",
    ...
},

@moloni-pt
Copy link

Thank you @Durzo84 for the information! Your steps solved my issue. Here are my package.json scripts for accomplishing these tasks after install:

"scripts": {
    "copybinding": "copy .\\node_modules\\msnodesqlv8\\bindingdotgyp.old .\\node_modules\\msnodesqlv8\\binding.gyp",
    "rebuild": "cd .\\node_modules\\.bin\\ && electron-rebuild -f -w msnodesqlv8 --module-dir ..\\..\\",
    "movenode": "move .\\node_modules\\msnodesqlv8\\bin\\win32-x64-69\\msnodesqlv8.node .\\node_modules\\msnodesqlv8\\lib\\bin\\msnodesqlv8.node",
    "postinstall": "npm run copybinding && npm run rebuild && npm run movenode",
    ...
},

Works like a charm. Any way of using electron-builder instead of the rebuild?

@TimelordUK
Copy link
Owner

thanks for the great information I shall add this to the wiki - in most recent release I have included electron v5 builds against nodes version 10, 11 and 12 I am not sure if this will help however.

@smithGit
Copy link

If anyone is still monitoring this thread, I am facing the same problem. I have mssql working in vanilla electron, but having problems implementing with the Quasar Framework (which uses Webpack). Initial error was (Webpack 'require' is not a function) but I added msnodesqlv8, which cleared that error but raised "none of the binaries loaded" which is the topic of this thread. I tried the scripts in package.json above, but that did not clear the problem. I am at version 10.16.0 of Node, 0.8.3 of msnodesqlv8, 5.1.0 of mssql. I am hoping that someone by now has harmonized these packages, and there is some way to ensure that the packages loaded play together. If anyone has suggestions on a streamlined manner to get this all to work together, I would appreciate guidance.

@JohnGagliardi
Copy link

JohnGagliardi commented Oct 1, 2019

thanks for the great information I shall add this to the wiki - in most recent release I have included electron v5 builds against nodes version 10, 11 and 12 I am not sure if this will help however.

You are a lifesaver. I didn't realize I was on electron v6. Also, note to those that have trouble using electron-rebuild, I was able to get stuff working by making sure my node version matched the one electron packages

@arkaydeus
Copy link

Any advice on this:
Currently using:
Node: v10.16.1
Electron: 6.0.11
msnodesqlv8: 0.8.4

I'm trying to use:
"rebuild": "cd .\\node_modules\\.bin\\ && electron-rebuild -f -w msnodesqlv8 --module-dir ..\\..\\",

But it doesn't seem to be rebuilding. Also I don't have a bindingdotgyp.old file.

Is there any way to force rebuild other than the above and where can I get the bindingdotgyp.old file?

@TimelordUK
Copy link
Owner

TimelordUK commented Oct 2, 2019 via email

@arkaydeus
Copy link

@TimelordUK - That would be why. Thanks for your swift response.

@smithGit
Copy link

smithGit commented Jan 31, 2020

Thanks for this discussion. I have re-installed electron v5.0.13 but the "none of binaries loaded" error still exists. Getting critical dependency error re ./node_modules/msnodesqlv8/lib/bootstrap.js. Any chance that electron current version 7-something can be supported? Thanks - I have mssql working in non-electron mode and it is great.

@abdulmansour
Copy link

@TimelordUK facing the same issue aswell when trying to run electron < v5... followed the steps mentioned yet to no avail.

@mtriff
Copy link
Collaborator

mtriff commented Mar 27, 2020

As of v1.0.1, binaries are no longer loaded via this method. Upon installing the latest version, npm will attempt to download the prebuilt binary for your specific version of node and electron. If a prebuilt version is not available, it will attempt to build the binary directly using node-gyp.

Please note that the scripts posted above by @moloni-pt are no longer required.

@mtriff mtriff closed this as completed Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests