【问题标题】:Gulp sass returning Error: python2 not foundGulp sass 返回错误:找不到 python2
【发布时间】:2018-10-31 11:01:23
【问题描述】:

这是我尝试像这样安装 gulp-sass 时看到的:

npm i gulp-sass --save-dev

运行 gulp-watchgulp browser-sync 有效

TIA

【问题讨论】:

    标签: npm cmd gulp-sass


    【解决方案1】:

    正如错误消息所示,您可能没有安装 python。 node-sass 库从源代码编译 libsass。为此,它使用node-gyp。要在 windows 下构建,readme 建议:

    在 Windows 上

    选项 1

    在提升的 PowerShell 或 CMD.exe(以管理员身份运行)中使用 npm install --global --production windows-build-tools 使用 Microsoft 的 windows-build-tools 安装所有必需的工具和配置。

    选项 2

    手动安装工具和配置:

    • 安装 Visual C++ 构建环境:Visual Studio Build Tools(使用“Visual C++ 构建工具”工作负载)或Visual Studio 2017 Community(使用“使用 C++ 进行桌面开发”工作负载)
    • 安装 Python 2.7(不支持 v3.x.x),然后运行 ​​npm config set python python2.7(或参见下文了解有关指定正确 Python 版本和路径的更多说明。)
    • 启动 cmd,npm config set msvs_version 2017

    如果上述步骤对您不起作用,请访问 Microsoft's Node.js Guidelines for Windows 获取更多提示。

    如果您安装了多个 Python 版本,您可以通过设置 '--python' 变量来识别 node-gyp 使用哪个 Python 版本:

    node-gyp --python /path/to/python2.7
    

    如果通过 npm 调用 node-gyp 并且您安装了多个版本的 Python,那么您可以将 npm 的 'python' 配置键设置为适当的值:

    npm config set python /path/to/executable/python2.7
    

    【讨论】:

      猜你喜欢
      • 2016-01-23
      • 1970-01-01
      • 2018-07-13
      • 2018-10-19
      • 1970-01-01
      • 2016-04-04
      • 2015-09-15
      相关资源
      最近更新 更多