【问题标题】:Installing scss-lint with npm without Python在不使用 Python 的情况下使用 npm 安装 scss-lint
【发布时间】:2016-06-03 13:48:52
【问题描述】:

我正在尝试让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,输出中的这个sn-p:

 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 问题,但如果是这样,我可能需要一些帮助(学习如何)find( ing)找出什么包或工具给我带来了麻烦(gulp-scss-lint?scss-lint?npm?node-sass 或其他一些底层包?)。

【问题讨论】:

    标签: npm gulp node-sass scss-lint


    【解决方案1】:

    您可以通过直接从github repository 克隆或下载该软件包并将其放置到您的目标位置来手动安装该软件包。

    注意:

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

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

    【讨论】:

    • 谢谢,这句话很有帮助。它并没有完全回答我的主要问题(“拥有 Python 真的是一个硬性要求吗?/你可以在没有 Python 的情况下安装吗?”)——因为我不想要拥有 Python在我的机器上只是为了能够使用一些 NPM 包。
    • 谢谢?。遗憾的是它需要 Python,有趣的是,当“数百人”依赖它时,我在开发 Express/Angular/Vue/etc 应用程序时从未遇到过这种限制......
    猜你喜欢
    • 1970-01-01
    • 2015-09-25
    • 2011-08-12
    • 2015-10-20
    • 2023-04-01
    • 1970-01-01
    • 2016-05-21
    • 2020-01-04
    相关资源
    最近更新 更多