NPM native builds with only Visual Studio 2013 installed

后端 未结 5 1288
隐瞒了意图╮
隐瞒了意图╮ 2021-02-14 04:27

I\'ve got a clean install of Windows with Visual Studio 2013 Pro installed, along with current versions of Python, node and npm.

I\'m trying to install the pg

5条回答
  •  悲&欢浪女
    2021-02-14 04:54

    Updated node-gyp to the latest version (1.0.2) by: npm install node-gyp -g

    Note that you also have to update the node-gyp that is internally used by node

    Now, node-gyp will support your Visual Studio 2013 - you can check in the /node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py, in _CreateVersion method.

    However, the native modules still won't build, giving an error that some include files are missing (ones from Windows SDK, like say winsock2.h). That is because Visual Studio 2013 is bundled with 7.1A SDK as the default. But default Toolset setting is 'v120', which expects the 8.1 SDK (which needs to be installed additionally).

    To build with just the stock VS 2013, you need to change what toolset is being selected. You can do that by modifying ~/.node-gyp/common.gypi file (idea taken from here), and changing the toolset to 'v120_xp' instead (which will use the bundled 7.1A SDK):

    { ... 'target_defaults': { ... 'configurations': { ... 'Release': { 'conditions': [ ['target_arch=="x64"', { 'msvs_configuration_platform': 'x64', 'msbuild_toolset': 'v120_xp' <--- THIS LINE! }], } } } }

    Voila - now the native npm modules will compile with the stock Visual Studio 2013 install!

提交回复
热议问题