【问题标题】:gulp-angular-templatecache no such file or directory, lstat 'templates.js' errorgulp-angular-templatecache 没有这样的文件或目录,lstat 'templates.js' 错误
【发布时间】:2016-06-17 14:59:22
【问题描述】:

我有这个用于构建我的角度模板的基本设置。

这是gulpfile

var gulp = require("gulp"),
    templateCache = require('gulp-angular-templatecache');

gulp.task("tc", function() {
    return gulp
        .src("test.html")
        .pipe(templateCache()) // when I comment out this line I see test.html file is getting copied under dest folder
        .pipe(gulp.dest("dest"));
});

这是一个简单的 html 文件,位于 gulpfile 旁边。

<div>
    Test
</div>

当我运行“gulp tc”时,出现以下错误。

[17:49:19] Using gulpfile ~SOME_PATH/gulpfile.js
[17:49:19] Starting 'tc'...
fs.js:839
  return binding.lstat(pathModule._makeLong(path));
                 ^

Error: ENOENT: no such file or directory, lstat '/SOME_PATH/templates.js'
    at Error (native)
    at Object.fs.lstatSync (fs.js:839:18)
    at DestroyableTransform.TransformStream [as _transform] (/SOME_PATH/node_modules/gulp-angular-templatecache/node_modules/gulp-header/index.js:38:12)
    at DestroyableTransform.Transform._read (/SOME_PATH/node_modules/gulp-angular-templatecache/node_modules/gulp-header/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:159:10)
    at DestroyableTransform.Transform._write (/SOME_PATH/node_modules/gulp-angular-templatecache/node_modules/gulp-header/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:147:83)
    at doWrite (/SOME_PATH/node_modules/gulp-angular-templatecache/node_modules/gulp-header/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:313:64)
    at writeOrBuffer (/SOME_PATH/node_modules/gulp-angular-templatecache/node_modules/gulp-header/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:302:5)
    at DestroyableTransform.Writable.write (/SOME_PATH/node_modules/gulp-angular-templatecache/node_modules/gulp-header/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:241:11)
    at write (/SOME_PATH/node_modules/gulp-concat/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)
    at flow (/SOME_PATH/node_modules/gulp-concat/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:632:7)

这就像“Hello World”练习一样简单,但我无法让它发挥作用。我在mac-os,ubuntu和windows机器上试过了,没有任何运气,总是同样的错误。我哪里错了?

顺便说一句,package.json 中的依赖项看起来像这样。

  "dependencies": {
  },
  "devDependencies": {
    "gulp": "^3.9.1",
    "gulp-angular-templatecache": "^1.8.0"
  }

编辑:如果我将一个空的 templates.js 文件添加到它要查找的位置,它就可以工作。

【问题讨论】:

  • 我现在遇到了确切的错误,它让我发疯。希望s.o能给我答案....

标签: javascript npm gulp


【解决方案1】:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-29
    • 2021-06-10
    • 2023-01-02
    • 2019-12-29
    • 2017-05-24
    • 2019-07-25
    • 2021-10-31
    • 1970-01-01
    相关资源
    最近更新 更多