How do I get node-gyp to work on Windows 7 platform

后端 未结 3 1818
北海茫月
北海茫月 2020-12-29 08:01

My attempts to use node-gyp on a Windows 7 + Node.js platform have failed [3] when attempting to compile the standard \"Hello World\" example [2]. Note: node-gyp is failing

相关标签:
3条回答
  • 2020-12-29 08:26

    Although this question is one month old, i ended up searching across the web and this was part of search results.

    So here is a not-should-do-but-it-works answer.

    First, i'm not familiar with node-gyp or the whole visual studio compile and stuff, i really really feel sorry for node-gyp depending on python (a really silent WTF )

    So for no known reason nodejs version older than 0.10.22 (i'm running that now so i assume there it where it starts)

    If you search your system for the file "uv.h" you might get some results IF you have previously installed nodejs versions, otherwise you could keep reading.

    my previous 0.10.3 nodejs version had uv.h into node-gyp some like

    <DRIVERLETTER>:\Users\<USERNAME>\.node-gyp\0.10.3\deps\uv
    

    so if you read the npm documentation you will find the the argument on npm install

    The --nodedir=/path/to/node/source argument will allow npm to find the node source code so that npm can compile native modules.

    so the final command should be

    npm install <package> --nodedir="<DRIVERLETTER>:\Users\<USERNAME\.node-gyp\0.10.3"
    

    you might get some warnings but it should complete with success.

    0 讨论(0)
  • 2020-12-29 08:34

    This is what helped me resolve it:

    For some reason i had node-gyp in two different directories.

    Directory 1:

    C:\Users\Imran Bughio\.node-gyp\0.10.21\
    

    Directory 2:

    C:\Users\Imran Bughio\Documents\.node-gyp\0.10.21\
    


    In 2nd directory i had a uv folder inside deps folder but that folder was not there in 1st directory.

    Here is the path -- note it had uv.h file inside.

    C:\Users\Imran Bughio\.node-gyp\0.10.21\deps\uv
    

    SOLUTION:

    I simply moved the uv & all the other extra folders from directory 2 to directory 1.

    @Phoenix answer gave me a little hint, which ultimately helped me resolve this so, Thanks Phoenix.

    0 讨论(0)
  • 2020-12-29 08:35

    Before you do anything, update Node and NPM by installing from the the node website (updating node and npm via npm appears to be busted on Windows. I'm not sure those delete-and-reinstall-everything-in-order instructions are current but that would most certainly be a major PITA which was what inspired me to look for alternatives given that that post was a little old in node years.

    Ultimately, this resolved an issue for me with node-gyp as a dependency for the pg module and it ran with vs 2013, I believe (or at least that's what it appeared to be looking for before it started working).

    0 讨论(0)
提交回复
热议问题