gulp-angular-templatecache没有这个文件或目录,lstat 'templates.js'错误。

11

我有一个基本的设置来构建我的Angular模板。

这是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 文件,它就可以工作。


我现在遇到了完全相同的错误,它让我疯狂。希望有人能给我答案... - Phong Lu
1个回答

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接