Gulp 吞咽错误-';没有指定路径!无法获取相对值;
我在Visual Studio 2013的项目中使用了Gulp 我把所有的项目都转移到了新的开发机器上。在这个项目中,我使用的是Gulp。以下是我在gulpfile.js中的任务:Gulp 吞咽错误-';没有指定路径!无法获取相对值;,gulp,Gulp,我在Visual Studio 2013的项目中使用了Gulp 我把所有的项目都转移到了新的开发机器上。在这个项目中,我使用的是Gulp。以下是我在gulpfile.js中的任务: config = { scripts: { src: "./app", destination: "./scripts/app" }, templates: { src: "./app/**
config = {
scripts: {
src: "./app",
destination: "./scripts/app"
},
templates: {
src: "./app/**/*.tmpl.html",
destination: "./scripts/app",
filename: "templates"
},
build: {
src: "./scripts/app/*.js",
destination: "./scripts/build",
filename: "dashboard-build"
}
}
gulp.task("templates", function () {
gulp.src(config.templates.src)
.pipe(html2js({
outputModuleName: "templates",
useStrict: true
}))
.pipe(concat(config.templates.filename + ".js"))
.pipe(gulp.dest(config.templates.destination))
});
当我尝试启动任务命令提示符窗口时,出现以下错误:
C:\Development\Repositories\Tambaound\Tambaound.Web>gulp templates
[17:04:59] Using gulpfile C:\Development\Repositories\Tambaound\Tambaound.Web\gulpfile.js
[17:04:59] Starting 'templates'...
[17:04:59] Finished 'templates' after 12 ms
C:\Development\Repositories\Tambaound\Tambaound.Web\node_modules\gulp-html2js\node_modules\gulp-util\node_modules\vinyl\index.js:120
if (!this.path) throw new Error('No path specified! Can not get relative.');
^
Error: No path specified! Can not get relative.
at File.get (C:\Development\Repositories\Tambaound\Tambaound.Web\node_modules\gulp-html2js\node_modules\gulp-util\node_modules\vinyl\index.js:120:27)
at Stream.bufferContents (C:\Development\Repositories\Tambaound\Tambaound.Web\node_modules\gulp-concat\index.js:35:20)
at Stream.stream.write (C:\Development\Repositories\Tambaound\Tambaound.Web\node_modules\gulp-concat\node_modules\through\index.js:26:11)
at DestroyableTransform.ondata (C:\Development\Repositories\Tambaound\Tambaound.Web\node_modules\gulp-html2js\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:531:20)
at emitOne (events.js:96:13)
at DestroyableTransform.emit (events.js:188:7)
at readableAddChunk (C:\Development\Repositories\Tambaound\Tambaound.Web\node_modules\gulp-html2js\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:198:18)
at DestroyableTransform.Readable.push (C:\Development\Repositories\Tambaound\Tambaound.Web\node_modules\gulp-html2js\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:157:10)
at DestroyableTransform.Transform.push (C:\Development\Repositories\Tambaound\Tambaound.Web\node_modules\gulp-html2js\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:123:32)
at DestroyableTransform._flush (C:\Development\Repositories\Tambaound\Tambaound.Web\node_modules\gulp-html2js\index.js:75:14)
在我的旧机器上,所有的工作都很好,而在新开发机器上的所有其他任务都很好。我如何解决这个问题 您可能在这两台机器上使用了不同版本的
gulp-html2js
下面是一个直接取自gulp-html2js的示例:
gulp.src('templates/*.html')
.pipe(html2js({
outputModuleName: 'template-test',
useStrict: true,
target: 'js'
}))
这看起来很像您试图使用的代码
但是,以下是取自(最新版本)的相同示例:
注意到区别了吗?ouputModuleName
选项似乎已重命名为name
。html2js()
的第一个参数现在是新模块的文件名。您的代码缺少这个,这就是为什么没有指定路径代码>错误
通常这样的事情不应该发生。模块应该遵循,像这样的破坏性更改应该只在主要版本更改中引入。然而,v0.x.x:
主要版本0(0.y.z)用于初始开发。任何事情都可能随时改变。公众空气污染指数不应被认为是稳定的
您有两个选择:
确保安装与旧机器上相同版本的gulp-html2js
。使用v0.3.1应做到:
npm install --save-dev gulp-html2js@0.3.1
调整任务,使其与上面版本0.4.2示例中的任务相似。政府应该会帮你的
(你也可以考虑改用,这是一个与之竞争的插件,它似乎在完成同样的任务,但下载量大约是它的三倍。)
npm install --save-dev gulp-html2js@0.3.1