D
D
DmitriySin2016-01-07 02:08:25
gulp.js
DmitriySin, 2016-01-07 02:08:25

Error while running gulp html:build?

created a package.json document

{
  "name": "habr",
  "version": "1.0.0",
  "description": "",
  "author": "",
  "license": "ISC",
  "dependencies": {
    "gulp": "^3.8.11"
  },
  "devDependencies": {
    "gulp-load-plugins": "^1.2.0",
    "gulp-rigger": "^0.5.8"
  }
}

Created gulpfile.js
'use strict';

var gulp = require('gulp'),    
    rigger = require('gulp-rigger');
   


var path = {
    build: { //Тут мы укажем куда складывать готовые после сборки файлы
        html: 'build/',
        js: 'build/js/',
        css: 'build/css/',
        img: 'build/img/',
        fonts: 'build/fonts/'
    },
    src: { //Пути откуда брать исходники
        html: 'src/*.html', //Синтаксис src/*.html говорит gulp что мы хотим взять все файлы с расширением .html
        js: 'src/js/main.js',//В стилях и скриптах нам понадобятся только main файлы
        style: 'src/style/main.scss',
        img: 'src/img/**/*.*', //Синтаксис img/**/*.* означает - взять все файлы всех расширений из папки и из вложенных каталогов
        fonts: 'src/fonts/**/*.*'
    },
    watch: { //Тут мы укажем, за изменением каких файлов мы хотим наблюдать
        html: 'src/**/*.html',
        js: 'src/js/**/*.js',
        style: 'src/style/**/*.scss',
        img: 'src/img/**/*.*',
        fonts: 'src/fonts/**/*.*'
    },
    clean: './build'
};

gulp.task('html:build', function () {
    gulp.src(path.src.html) //Выберем файлы по нужному пути
        .pipe(rigger()) //Прогоним через rigger
        .pipe(gulp.dest(path.build.html)) //Выплюнем их в папку build
        .pipe(reload({stream: true})); //И перезагрузим наш сервер для обновлений
});

gulp html:build on the command line throws the following error
folder path/gulp test$ gulp html:build
Command 'gulp' not found, did you mean:
Command 'gslp' from package 'ghostscript' (main)
gulp: command not found

Answer the question

In order to leave comments, you need to log in

4 answer(s)
O
olegshilov, 2016-08-01
@olegshilov

either install galp globally
or run galp via npm scripts

{
  "scripts": {
    "build": "gulp html:build"
  }
}

D
DmitriySin, 2016-01-07
@DmitriySin

At the moment, another error with what can be connected?

[01:46:12] Using gulpfile /media/dmitriy/62F235C5F2359E6B/work/git/elephantcode/Dima/gulp test/gulpfile.js
[01:46:12] Starting 'html:build'...
[01:46:12] 'html:build' errored after 5.89 ms
[01:46:12] ReferenceError: reload is not defined
    at Gulp.<anonymous> (/media/dmitriy/62F235C5F2359E6B/work/git/elephantcode/Dima/gulp test/gulpfile.js:29:15)
    at module.exports (/media/dmitriy/62F235C5F2359E6B/work/git/elephantcode/Dima/gulp test/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/media/dmitriy/62F235C5F2359E6B/work/git/elephantcode/Dima/gulp test/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/media/dmitriy/62F235C5F2359E6B/work/git/elephantcode/Dima/gulp test/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/media/dmitriy/62F235C5F2359E6B/work/git/elephantcode/Dima/gulp test/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
    at /usr/local/lib/node_modules/gulp/bin/gulp.js:129:20
    at process._tickCallback (node.js:415:13)

buffer.js:188
        throw new TypeError('First argument needs to be a number, ' +
              ^
TypeError: First argument needs to be a number, array or string.
    at new Buffer (buffer.js:188:15)
    at /media/dmitriy/62F235C5F2359E6B/work/git/elephantcode/Dima/gulp test/node_modules/gulp-rigger/index.js:20:29
    at Rigger.<anonymous> (/media/dmitriy/62F235C5F2359E6B/work/git/elephantcode/Dima/gulp test/node_modules/gulp-rigger/node_modules/rigger/index.js:719:9)
    at Rigger.EventEmitter.emit (events.js:95:17)
    at /media/dmitriy/62F235C5F2359E6B/work/git/elephantcode/Dima/gulp test/node_modules/gulp-rigger/node_modules/rigger/index.js:252:16
    at /media/dmitriy/62F235C5F2359E6B/work/git/elephantcode/Dima/gulp test/node_modules/gulp-rigger/node_modules/rigger/node_modules/async/lib/async.js:232:13
    at /media/dmitriy/62F235C5F2359E6B/work/git/elephantcode/Dima/gulp test/node_modules/gulp-rigger/node_modules/rigger/node_modules/async/lib/async.js:113:21
    at /media/dmitriy/62F235C5F2359E6B/work/git/elephantcode/Dima/gulp test/node_modules/gulp-rigger/node_modules/rigger/node_modules/async/lib/async.js:24:16
    at /media/dmitriy/62F235C5F2359E6B/work/git/elephantcode/Dima/gulp test/node_modules/gulp-rigger/node_modules/rigger/node_modules/async/lib/async.js:229:17
    at /media/dmitriy/62F235C5F2359E6B/work/git/elephantcode/Dima/gulp test/node_modules/gulp-rigger/node_modules/rigger/index.js:391:21

L
lavezzi1, 2016-01-07
@lavezzi1

Either you didn't post the whole gulp.js. Either the indication in the header file var = plugin to reload is missing. Because you use it
But not connected. Set up the gulp-browsersync plugin and update the line to match

M
Max Donchenko, 2016-07-27
@GoodWin64

Absolutely the same problem.
I have Ubuntu 14.0
SOLUTION that worked for me: add path to node_modules/.bin folder to system PATH variable:

export PATH=$PATH:.node_modules/.bin:../node_modules/.bin

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question