5

我正在尝试gulp-scss-lint在我的机器上工作,但在这样做时遇到了麻烦。

语境

我感觉特定版本和环境设置可能对我的问题很重要,所以让我列出我的特定上下文:

  • Windows Server 2012 R2 标准版
  • NPM 2.14.7
  • 节点 4.2.2
  • 安装了 Gulp 3.9.0-g
  • 从 Powershell 4.0 运行

复制品

这是我的问题的重现:

  1. mkdir gulpscsslintcd gulpscsslint
  2. npm init所有默认答案
  3. npm install gulp --save-dev
  4. npm install gulp-scss-lint --save-dev
  5. new-item -itemtype file gulpfile.js并输入:

    var gulp = require('gulp'), lint = require('gulp-scss-lint');
    gulp.task('default', [], function() {
      return gulp.src('*.scss').pipe(lint());
    });
    
  6. new-item -itemtype file styles.scss

  7. gulp

结果:

 [08:48:50] Using gulpfile ~\experiments\gulpscsslint\gulpfile.js
 [08:48:50] Starting 'default'...
 [08:48:50] 'default' errored after 32 ms
 [08:48:50] Error in plugin 'gulp-scss-lint'
 Message:
     Error code 1
 Error: Command failed: C:\Windows\system32\cmd.exe /s /c "scss-lint 'styles.scss' --format=JSON"
 'scss-lint' is not recognized as an internal or external command,
 operable program or batch file.

预期的结果显然是 linter 的实际输出。

于是我继续说:

  1. npm install scss-lint --save-dev

但它失败了failNoPython,输出中的这个片段:

 Can not download file from https://raw.githubusercontent.com/sass/node-sass-binaries/v2.1.1/win32-x64-node-4.2/binding.node
 gyp ERR! configure error
 gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable

问题

让Python安装这个 Node 包真的是一个硬性要求吗?还是可以在不安装 Python 的情况下以某种方式安装它?

作为一个脚注,既然我已经完全写了这个问题,我意识到这可能更像是一个 Github 问题,但如果是这样,我可能需要一些帮助(学习如何)找出什么包或工具给了我麻烦(gulp-scss-lint? scss-lint? npm?node-sass或其他一些底层包?)。

4

1 回答 1

1

您可以通过直接从其github 存储库克隆或下载包并将其放置到目标位置来手动安装包。

笔记:

node-gyp 是一个用 Node.js 编写的跨平台命令行工具,用于为 Node.js 编译本机插件模块。关联

这个包需要 Python 才能工作。数百个包,包括npmnpminstall,都依赖 node-gyp 来编译。在 Windows 上,人们可以安装包 windows-build-tools,其中包括 python,以使用 node-gyp。

于 2019-04-03T22:00:09.117 回答