【问题标题】:processing multiple files with gulp-pug使用 gulp-pug 处理多个文件
【发布时间】:2016-12-23 08:29:12
【问题描述】:

我想使用 gulp 将我的 pug 文件预处理为 html 文件。目前我的“默认”脚本中有这个:

gulp.watch([
    'app/partials/**.pug',
    'app/index.pug'], ['views-compile']
);

我的'views-compile'函数如下

var pug = require('gulp-pug2');

gulp.task('views-compile', function(){
    return gulp.src([
        'app/partials/**.pug',
        'app/index.pug'
    ])
    .pipe(pug.compile())
    .pipe(gulp.dest('app/views/'))
})

当我运行此任务时,我收到文件已存在的错误

C:\dev\my-project>gulp views-compile
[09:18:01] Using gulpfile C:\dev\my-project\gulpfile.js
[09:18:01] Starting 'views-compile'...
[09:18:01] 'views-compile' errored after 190 ms
[09:18:01] Error: EEXIST: file already exists, mkdir 'C:\dev\my-project\app\views'
    at Error (native)

我可以做些什么来解决这个问题并使用 *.pug 手表处理我的所有 pug 文件?

【问题讨论】:

  • 检查app/views 不是现有文件的名称。除此之外,如果您希望有人能够帮助您,您必须提供一个重现问题的minimal reproducible example

标签: gulp pug


【解决方案1】:

我已经通过以下步骤解决了这个问题:

  1. 添加了 NODE_PATH 作为系统变量,其值为: %AppData%\npm\node_modules
  2. 首先在 PATH 中添加了“%AppData%\npm\”
  3. 全局安装 gulp
  4. 在项目中本地安装 gulp
  5. 全局安装 gulp-cli
  6. 在项目中本地安装 gulp-cli

注销并重新登录,以应用设置。 在互联网上的不同地方,您会发现在 PATH 中添加 %AppData%\npm\node_modules 但在我的情况下这不起作用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-17
    • 2015-03-07
    • 1970-01-01
    • 1970-01-01
    • 2021-10-06
    • 2017-08-17
    • 1970-01-01
    • 2021-07-01
    相关资源
    最近更新 更多