igorklopov / enclose

Compile your Node.js project into an executable
http://enclosejs.com
Other
936 stars 43 forks source link

Native dependencie node-sqlserver-unofficial, how face it #23

Closed estvmachine closed 9 years ago

estvmachine commented 9 years ago

Hi, i try to make executable version of my project which include a node-sqlserver-unofficial (https://www.npmjs.com/package/node-sqlserver-unofficial).

var enclose = require("enclose").exec;
var flags = [];
var x64 = process.arch === "x64";
if (x64) flags.push("--x64");

try {
  require.resolve("./node-sqlserver-unofficial");
} catch(error) {
  console.log("Failed to require('node-sqlserver-unofficial')");
  console.log("Please run 'npm install' here");
  process.exit(1);
}

flags.push("./index.js");
enclose(flags);

I can make the executable, but in my system i got dependencies for 'node-sqlserver-unofficial' and this folder got a 'javascript' file and one native module (.node). "I think" i have to call this native module from this "javascript" file and the native module MUST be outside the package, otherwise the package its not created.

So i need to call the dependence

  sql = require('node-sqlserver-unofficial'),

In nodemodules/node-sqlserver-unofficial, i suppose the 'root' its gonna be the same 'root' of my executable file.

   module.exports= require('./bin/0.10-x64/sqlserver.node');

When i compile, i obtain this warning:

$ node compile.js

c:\Users\EstebanFrancisco\Proyectos\dest_V2\node_modules\node-sqlserver-unoffici
al\lib\bin\0.10-x64\sqlserver.node
  warning  Cannot include native addon into executable
  The addon package must be distributed with executable

c:\Users\EstebanFrancisco\Proyectos\dest_V2\node_modules\scribe-js\node_modules\
colors\lib\colors.js
  warning  Cannot resolve 'require(theme)'
  Use a string literal as argument for 'require', or leave it
  as is and specify the resolved file name in 'scripts' option
igorklopov commented 9 years ago

EncloseJS has node 0.12.x (or iojs) inside. So you can not attach modules, built for 0.10. Besides, i did not find sources in the repo: https://github.com/jorgeazevedo/node-sqlserver-unofficial. So i can not rebuid for 0.12 myself.

estvmachine commented 9 years ago

Oh I understand the problem. Well, I use node- sqlserver- unofficial because its compiled and when I try to compile for my own dont go well for inexperience , the source can be obtained from here https://github.com/Azure/node-sqlserver . If you can give me some advice to make a version for 0.12.x , I will be very grateful.

tracker1 commented 9 years ago

@estvmachine My own experience with the binary sqlserver module for node has been really poor. It also tends to only work on Windows. I've had much better luck using mssql using the default driver tedious ... if you're using babel (or another ES6 implementation), I wrote a pretty nice ES6 template interface with mssql-ng

Tedious is itself a JavaScript interface to TDS (MS-SQL), and has worked everywhere I've needed it, be that Linux, Windows and OSX.

estvmachine commented 9 years ago

I am using the driver tedious directly , and the truth is that works very well with Enclose.js :)

@tracker1 im not using Babel, but thank you for the recomendation I should have used Tedious since the beginning :+1:

tracker1 commented 9 years ago

@estvmachine sure thing... since MS themselves stopped supporting the binary driver, I really wish that it would just disappear in favor of Tedious, since it's really the only client that's been continuously updated... I do like what mssql provides over the top (a simpler interface, and connection pooling). I wrote the mssql-ng mainly to make migrating off of mssql for my current project easier to write.

estvmachine commented 9 years ago

@tracker1 Sorry for not answering quickly , I was a little sick. I check your code , and I think is a great contribution , allow write queries more like MSSQL , im gonna check in the future :) , for the moment i use mssql like you recomended.

@igorklopov or @tracker1 I have other question and maybe im gonna open an issue in the future for this, but my question is with Scribe.js (https://github.com/bluejamesbond/Scribe.js/tree/master) or other method for logging. Im gonna need read or writes files outside the executable path, same thing happen if I use SQLite. I know this is supported but dont have it at all clear, its something like i post in the init of this Issue?. Well this gonna be the following challenges later readapting my project for mssql.