Tag: gulp

npm安装不起作用

操作系统的Windows 7 64位 当我使用npm install gulp时,npm不起作用。 我很困扰…. 错误代码: npm ERR! Error: connect ECONNREFUSED npm ERR! at errnoException (net.js:878:11) npm ERR! at Object.afterConnect [as oncomplete] (net.js:869:19) npm ERR! { [Error: connect ECONNREFUSED] npm ERR! code: 'ECONNREFUSED', npm ERR! errno: 'ECONNREFUSED', npm ERR! syscall: 'connect' } npm ERR! npm ERR! If you are behind a proxy, please […]

如何使用gulp自动添加其他HTML文件的链接到index.html?

就像WordPress博客上的存档页面一样。 我正在使用这个gulp脚本,它可以生成多个页面,但只能运行一次服务器并在浏览器中打开页面时才显示一次。 server: { baseDir: "./output", index: "test-template.html" }, 我想要test-template.html应该有链接 templateA.html templateB.html templateC.html 所以在浏览器中,而不是记住和input这些文件的URL,我可以通过点击index.html页面上的链接来打开 有没有插件来做到这一点?

Node.js:我如何将全局variables传递给通过require()插入的文件?

我已经把我的gulpfile.js分成几个文件在一个/gulp gulpfile.js文件夹中,以便更好地组织代码。 但是现在我想将一个variablesdebug (boolean)传递给将会包含gulp命令的行为的文件(最终我将使用命令行参数,但现在我只想使它与variables一起工作)。 我使用的方法是使用我在一个yeoman angular / gulp包中看到的方法,它使用一个名为require-dir的npm模块(它将所有* .js文件加载到/gulp文件夹中,每个文件夹都有一个所设置的吞吐任务)。 gulpfile.js: var gulp = require('gulp'), run = require('run-sequence'), debug = true; require('require-dir')('./gulp'); gulp.task('default', ['build', 'server', 'watch', '…']); 这将加载像… 吞掉/ build.js: var gulp = require('gulp'), plumber = require('gulp-plumber'), …; gulp.task('build', function () { console.log(debug); }); 所以当我运行命令gulp ,运行default任务时,它将加载build.js,然后执行build gulp任务。 但不幸的是,似乎debug返回undefined。 我怎么能得到这个工作? 我正在使用module.exports()和节点的require()方法,但我无法弄清楚如何获取包含文件中的gulp任务来声明,以便它可以从主gulpfile.js文件运行gulpfile.js文件(以所需的顺序)。 任何人可以提供一些援助? 谢谢

我怎么能保证在我的应用程序中一次性使用吞咽?

作为我正在编写的一个小程序的一部分,我想用gulp将一大组文件转换为markdown。 这不是与程序分开的构build步骤的一部分。 这是该计划的一部分。 所以我没有使用gulpfile来处理这个问题。 问题是,因为它是asynchronous的,所以我想使用一个承诺,在吞吐任务完成时会提醒我。 像这样的东西将是理想的: io.convertSrc = function() { var def = q.defer(); gulp.src(src + '/*.md') .pipe(marked({})) .pipe(gulp.dest(dist), function() { def.resolve('We are done!'); }); return def.promise; } 但pipe不会callback。 我怎么处理这个? 感谢您的帮助,我有点新的吞噬。

为什么我得到这个错误? dest.on不是一个函数 – 使用gulp-file-include

我得到了TypeError: dest.on is not a function的错误TypeError: dest.on is not a function 。 运行这个任务时,我无法弄清楚什么是错的。 var fileinclude = require('gulp-file-include'); var rename = require('gulp-rename'); var paths = { templates : './templates/' } //file include: grab partials from templates and render out html files gulp.task('fileinclude', function() { return gulp.src(paths.templates + '*.tpl.html') .pipe(fileinclude) .pipe(rename({ extname: "" })) .pipe(rename({ extname: ".html" […]

设置一个Gulp任务是默认的

我在我的gulpFile有以下任务,由我的团队中的其他人创build: gulp.task('serve', [], function(){ gulp.run( 'fonts', 'browsersync', 'watch' ); }); 我想离开它,但我也想把默认任务映射到这个任务。 所以我试了一下: gulp.task('default',['serve']); 它似乎工作,在服务器运行,但由于某种原因,“观看”任务没有发生,我没有得到更改浏览器刷新。 这一切都按计划运行,如果我运行“吞噬服务”,而不是“吞咽”。 我做错了什么? 编辑:这是手表任务: gulp.task('watch', ['styles', 'browsersync'], function() { //'default' gulp.watch( [ './app/assets/sass/**/*.scss', './app/modules/**/*.scss' ], ['styles']); gulp.watch([ './app/**/*.js', './app/**/*.html' ], function() { reload(); }); });

npm install缺less模块

在我可以在我的项目中运行npm install之前,我需要运行npm install 。 这工作除了我的电脑,因为我得到以下错误: Error: Cannot find module 'socket.io' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) … 我可以解决这个问题 $> npm install socket.io 现在当我再次执行安装命令时, Error: Cannot find module 'di' … 当我安装di并再次运行安装命令时,我得到: Error: Cannot find module 'log4js' 我认为这可能会持续很长时间。 任何build议这里发生了什么,以及如何解决这个问题?

当我inputnpm start时如何开始Gulp监视任务

我有一个gulp.js文件,其中包括: gulp.task('default', ['watch']); 启动监视任务 gulp.task('watch', function(){ gulp.watch(productionScripts, ['autoConcat']); }); 然后,在任何已保存的对productionScripts文件所做的更改中,监视任务将对这些文件进行连接。 我想要做的,是在我的package.json中,当我键入npm start(这已经启动我的节点服务器)时,我想暂停此表。 的package.json "start": "node server.js", 更新 ——– 本(b3nj4m.com),我试过你所说的。 手表和服务器启动。 然而,一切都运行两次(可能是由于编辑器,而不是相关),但是当我用gulp启动它时,确实会丢失我的服务器日志。 [15:31:18] Starting 'autoConcat'… [15:31:18] Finished 'autoConcat' after 147 ms [15:31:19] Starting 'autoConcat'… [15:31:19] Finished 'autoConcat' after 138 ms [15:31:20] Starting 'autoConcat'… [15:31:20] Finished 'autoConcat' after 127 ms [15:31:23] Starting 'autoConcat'… 这就好像服务器在更改时重新启动和连接文件更改之间存在一个循环。

Gulp:目标是debugging摩卡testing

我有一套运行我的摩卡testing的gulp.js目标,这个testing的function就像是一个吞噬摩卡的魅力一样。 问题:如何debugging我的摩卡testing运行通过吞咽? 我想使用像node-inspector这样的东西在我的src中设置断点并testing文件来查看正在发生的事情。 我已经可以通过直接调用节点来实现这一点了: node –debug-brk node_modules/gulp/bin/gulp.js test 但是我更喜欢为我包装这个吞噬目标,例如: gulp.task('test-debug', 'Run unit tests in debug mode', function (cb) { // todo? }); 想法? 我想避免一个bash脚本或其他单独的文件,因为我正在尝试创build一个可重用的gulpfile ,这个文件可以被不知道吞咽的人使用。 这是我目前的gulpfile.js // gulpfile.js var gulp = require('gulp'), mocha = require('gulp-mocha'), gutil = require('gulp-util'), help = require('gulp-help'); help(gulp); // add help messages to targets var exitCode = 0; // kill process […]

Node.js – 自动刷新在Dev

我正在尝试改进我的节点中的DEV经验。 要做到这一点,我想: a)当服务器端代码改变时重启我的服务器 b)当客户端代码改变时刷新浏览器。 为了做到这一点,我开始将nodemon和browserSync集成到我的gulp脚本中。 在我的gulp脚本中,我有以下任务: gulp.task('startDevEnv', function(done) { // Begin watching for server-side file changes nodemon( { script: input.server, ignore:[input.views] }) .on('start', function () { browserSync.init({ proxy: "http://localhost:3002" }); }) ; // Begin watching client-side file changes gulp.watch([ input.css, input.js, input.html ], function() { browserSync.reload(); }); done(); }); 当上述任务运行时,我的浏览器打开到http:// localhost:3000 / 。 我的应用程序是可见的预期。 但是,在控制台窗口中,我注意到: […]