1

我正在尝试恢复我的自动化 KSS 构建过程,该过程在一年前在我为另一个项目升级 Node 后死亡。

当我通过命令行 ( $ ./node_modules/kss/bin/kss --config kss-config.json)直接运行 KSS 时,它运行良好

但是当我使用 node spawn 通过 gulp 运行它时,我收到以下错误:

user@computer /c/users/user/Documents/projects/kss
$ gulp
[12:04:42] Using gulpfile C:\users\user\Documents\projects\kss\gulpfile.js
[12:04:42] Starting 'default'...
[12:04:42] Starting 'compileKss'...
[12:04:42] 'compileKss' errored after 3.21 ms
[12:04:42] Error: spawn ./node_modules/kss/bin/kss ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
[12:04:42] 'default' errored after 6.78 ms

我的 gulp 文件如下所示:

'use strict'
/**
 * Some useful links to help with understanding this file:
 * * https://www.webstoemp.com/blog/switching-to-gulp4/
 */

const { series } = require('gulp')
const childProcess = require('child_process')

/**
 * a Gulp task for compiling Sass files to CSS and creating source maps
 */
const compileKss = (gulpCallBack) => {
  const kss = childProcess.spawn(
    './node_modules/kss/bin/kss',
    [
      '--config',
      './kss-config.json'
    ]
  )
  kss.on('exit', (code) => {
    const errorMsg = (code === 0) ? null : 'ERROR: kss-node process exited with code: ' + code
    gulpCallBack(errorMsg)
  })
  return kss
}

exports.default = series(compileKss)

我的 kss 配置文件如下所示:

{
  "title": "KSS style guide",
  "source": [
    "./style-guide/css/"
  ],
  "destination":  "./style-guide/",
  "homepage": "src/homepage.md",
  "builder": "node_modules/michelangelo/kss_styleguide/custom-template",
  "css": [],
  "js": []
}

我的 package.json 看起来像这样:

{
  "name": "KSS style-guide",
  "description": "KSS style-guide",
  "author": {},
  "browserslist": [
    "last 2 version",
    "> 1%"
  ],
  "bugs": {},
  "contributors": [],
  "dependencies": {},
  "devDependencies": {
    "acorn": "^7.1.0",
    "browser-sync": "^2.26.7",
    "compass-importer": "^0.4.1",
    "concat": "^1.0.3",
    "del": "^5.1.0",
    "fancy-log": "^1.3.3",
    "gulp": "^4.0.2",
    "gulp-concat": "^2.6.1",
    "gulp-plumber": "^1.2.1",
    "gulp-sass": "^4.0.2",
    "gulp-sass-lint": "^1.4.0",
    "gulp-sourcemaps": "^2.6.5",
    "gulp-terser": "^1.2.0",
    "gulp-uglify": "^3.0.2",
    "kss": "^3.0.0-beta.25",
    "michelangelo": "^0.8.0",
    "standard": "^14.3.1",
    "terser": "^4.3.9"
  },
  "engines": {"node": ">=12"},
  "engineStrict": true,
  "repository": {},
  "scripts": {},
  "version": "0.0.1"
}

仅供参考:我的系统正在使用

  • 窗口:10 (10.0.16299)
  • Git Bash (mintty 3.0.6) (GNU bash, 版本 4.4.23(1)-release (x86_64-pc-msys))
  • 节点:12.13.0
  • 吞咽:4.0.2
  • kss 节点:3.0.0-beta.25
4

0 回答 0