dinsdag 24 juli 2012

I wanted to add ldapjs to my Windows node.js project but...

I wanted to add ldapjs to my node.js project but encountered the issue that it does not install under windows node version 8. As stated there, the cause is that one of ldapjs dependency, dtrace-provider, is built using node-waf which does not work on Windows.
As a result, "npm install ldapjs" fails
977 error node -v v0.8.2978 error npm -v 1.1.36979 error code ELIFECYCLE980 error message dtrace-provider@0.0.9 install: node-waf clean ; node-waf configure build980 error message cmd "/c" "node-waf clean ; node-waf configure build" failed with 1981 verbose exit [ 1, true ]
It appeared that the solution is to use gyp instead of node-waf for building dtrace-provider. bfar did a part of the job by forking it and adding the gyp config file.

DailyJS "Windows and Nodes: Addons" describes how make the gyp compilation working on Windows by installing Python and Visual C++.
So I downloaded the sources of bfar's fork and executed this last tutorial and it worked! I got the dtrace-provider compiled.
The, "npm install ldapjs" on my project worked after copying the built dtrace-provider module folder under my node_modules folder. 
However, executing again the command from scratch (by emptying node_modules) was failing and the copy of the manually built dtrace-provider was not statisfactory (too many manual steps).
In order to streamline a little bit more the process, I modified the package.json of dtrace-provider and change the script command for the install stage. So I replaced
"scripts": { "install": "node-waf configure build" }
by
"scripts": { "install": "node-gyp rebuild" }
The updated package.json is here.
Finally, in my node.js project, I added the dependency to my fork of blar so that my project package.json contains
"dependencies": {
    "dtrace-provider": "git://github.com/itoche/node-dtrace-provider.git#binding-gyp"
     , "ldapjs": "0.5.4"
 }
Now, "npm install ldapjs" works fine.

12 opmerkingen:

  1. Hi Christophe.
    The Link "DailyJS "Windows and Nodes: Addons"" in your text is pointing to the wrong page - can you fix it?

    BeantwoordenVerwijderen
  2. I used the tutorial ... for a test i build node-fibers. worked.

    now i try to install ldapjs ... with no success.. and i do not understands the steps it took for you to get it installed.

    Can i install your fork with npm ?

    I do not understand this:
    I executed this last tutorial and it worked! "npm install ldapjs" worked after copying the built dtrace-provider module folder under node_modules. However, executing again the command from scratch (by emptying node_modules) was still failing.

    what worked? where is the "dtrace-provider module folder", then you executed again and it was failing? - still? why still?

    I would really like to get this to work. I hope you can provide a little bit more detailed info.

    Thank you for your work!

    BeantwoordenVerwijderen
    Reacties
    1. Thomas,

      I quickly tried to rephrase a little bit that part. Let me know if this is clearer now.
      If not, I will be happy to detail more.

      Christophe

      Verwijderen
    2. Deze reactie is verwijderd door de auteur.

      Verwijderen
    3. Deze reactie is verwijderd door de auteur.

      Verwijderen
    4. Deze reactie is verwijderd door de auteur.

      Verwijderen
  3. Deze reactie is verwijderd door de auteur.

    BeantwoordenVerwijderen
  4. Deze reactie is verwijderd door de auteur.

    BeantwoordenVerwijderen
    Reacties
    1. There was a problem with node-gyp today ... DAMN ;)
      https://github.com/TooTallNate/node-gyp/issues/122#issuecomment-7699530

      Verwijderen