A
A
Alexander Kotelnikov2016-06-17 18:57:13
gulp.js
Alexander Kotelnikov, 2016-06-17 18:57:13

Gulp sourcemaps Path must be a string error. How to treat?

Gulp crashes when including sourcemaps. I have already tried everything: I reinstalled the packages, and tried to update the node package 'source-map'. Nothing helped, I decided to ask here. Has anyone come across something similar? How to cure it?
Here gulpfile.js:

'use strict';

const gulp = require('gulp');
const stylus = require('gulp-stylus');
const sourcemaps = require('gulp-sourcemaps');
const del = require('del');

const isDevelopment = !process.env.NODE_ENV || process.env.NODE_ENV == 'development';

gulp.task('styles', function() {

  return gulp.src('frontend/styles/main.styl')
      .pipe( sourcemaps.init())
      .pipe(stylus())
      .pipe(sourcemaps.write())
      .pipe(gulp.dest('public'));

});

gulp.task('clean', function() {
  return del('public');
});

gulp.task('assets', function() {
  return gulp.src('frontend/assets/**')
      .pipe(gulp.dest('public'));
});


gulp.task('build', gulp.series(
    'clean',
    gulp.parallel('styles', 'assets'))
);

Here is the error:
test:$> gulp build

> [email protected] gulp /Users/alex/projects/test
> gulp "build"

[18:34:27] Using gulpfile ~/projects/test/gulpfile.js
[18:34:27] Starting 'build'...
[18:34:27] Starting 'clean'...
[18:34:27] Finished 'clean' after 10 ms
[18:34:27] Starting 'styles'...
[18:34:27] Starting 'assets'...
[18:34:27] 'styles' errored after 185 ms
[18:34:27] TypeError in plugin 'gulp-stylus'
Message:
    /Users/alex/projects/test/frontend/styles/main.styl:8:1
   4|   margin 0
   5|   padding 0
   6|   width 100%
   7|   height 100%
   8|
------^

Path must be a string. Received undefined

Details:
    domainEmitter: [object Object]
    domain: [object Object]
    domainThrown: false
[18:34:27] 'build' errored after 200 ms
[18:34:27] The following tasks did not complete: assets

Here are the versions:
node v6.2.1
npm  v3.9.3
test:$> npm view gulp-sourcemaps version
1.6.0
test:$> npm view source-map version
0.5.6
test:$> npm view gulp-stylus version
2.4.0
test:$> npm view stylus version
0.54.5

Moreover, if you comment out .pipe(gulpIf(isDevelopment, sourcemaps.init())), then everything works. Only sourcemaps, of course, is not written.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Efimov, 2019-05-12
@efiand

.pipe(sourcemaps.write(''))
try to give the string as requested

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question