windows10环境下安装node-gyp

3,154 阅读1分钟
  1. 打开powerShell(管理员模式)

    win +x 选择 Windows PowerShell(管理员)

  2. 安装C ++构建工具:npm i --vs2015 --global windows-build-tools

    • 容易发生的下面提示,直接重新安装,一定加上 --vs2015(--vs2017更新了最新的.net framework依旧不行,知道的朋友可以留言)
    • could not install Visual Studio Build Tools...
    • still waiting for installer log file ...(一定不要死等,不然会死的很惨,理解为安装报错)
  3. 安装node-gyp: npm i -g node-gyp

    • 报错提示

    if not defined npm_config_node_gyp(...

    • 解决方法改环境变量(win + r -> SystemPropertiesAdvanced.exe -> 环境变量 -> 用户path_ ) 1622537922(1).jpg
  4. 配置 npm config

    npm config set msvs_version 2015
    npm config set python C:\Users\allen\.windows-build-tools\python27

  5. 验证是否成功 image.png