学好node开发

常见报错及解决方案

node-gyp

node-gyp: Node.js native addon build tool.npm中有很多的库依赖了此编译工具,比如gulp-sass, browser-sync...而此工具又需要Visual C++VCBuild.exe编译,所以官方给出的依赖环境(on Windows)如下:

- Python (v2.7.3 recommended, v3.x.x is not supported)
    - Make sure that you have a PYTHON environment variable, and it is set to drive:\path\to\python.exe not to a folder.
- Windows XP/Vista/7:
    - Microsoft Visual Studio C++ 2013 (Express version works well)
        - If the install fails, try uninstalling any C++ 2010 x64&x86 Redistributable that you have installed first.
        - If you get errors that the 64-bit compilers are not installed you may also need the compiler update for the Windows SDK 7.1
- Windows 7/8:
    - Microsoft Visual Studio C++ 2013 for Windows Desktop (Express version works well)
- All Windows Versions
    - For 64-bit builds of node and native modules you will also need the Windows 7 64-bit SDK
    - You may need to run one of the following commands if your build complains about WindowsSDKDir not being set, and you are sure you have already installed the SDK:
        call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x86
        call "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\Setenv.cmd" /Release /x64

这里我下载的是vs2013 express for Windows Desktop版本。安装完成后会提示重启系统,再次安装相应模块即可。

参考资料