Cannot start netlify locally - netlify dev

Hi guys, I’ve just copied my boilerplate from previous netlify projects and noticed I cannot start netlify dev server. I’m getting the following:

Richards-MBP-2:wiecz Richard$ netlify dev
◈ Netlify Dev ◈
◈ Ignored general context env var: LANG (defined in process)
◈ Cannot read property ‘map’ of undefined

I believe the problem is somehow associated with gulp. Whenever I remove gulp from my devDependencies in package.json netlify dev starts normally. Of course if I remove the json file it also works - that’s how I started debugging it. I’ve checked all the dependencies and only gulp seems to matter. Please, I am not good at this build and deployment magic and I’ve been scratching my head the whole day.

This is my package.json (removing “gulp”: “^4.0.2”, solves the problem) :

{
“name”: “monitoring”,
“version”: “1.0.0”,
“description”: “”,
“main”: “main.js”,
“scripts”: {
“test”: “echo “Error: no test specified” && exit 1”
},
“author”: “Ryszard Waniek”,
“license”: “ISC”,
“devDependencies”: {
@babel/core”: “^7.11.0”,
@babel/preset-env”: “^7.11.0”,
“gulp”: “^4.0.2”,
“gulp-autoprefixer”: “^5.0.0”,
“gulp-babel”: “^8.0.0”,
“gulp-concat”: “^2.6.1”,
“gulp-cssnano”: “^1.1.0”,
“gulp-notify”: “^3.2.0”,
“gulp-rename”: “^1.4.0”,
“gulp-sass”: “^5.0.0”,
“gulp-sourcemaps”: “^2.6.5”,
“gulp-uglify”: “^3.0.2”,
“merge-stream”: “^2.0.0”,
“sass”: “^1.35.2”
}
}

and this is my gulp.js:

‘use strict’;

const gulp = require(‘gulp’);
const babel = require(‘gulp-babel’);
// const merge = require(‘merge-stream’);
const sass = require(‘gulp-sass’)(require(‘sass’));
const cssnano = require(‘gulp-cssnano’);
const sourcemaps = require(‘gulp-sourcemaps’);
const autoprefixer = require(‘gulp-autoprefixer’);
const rename = require(‘gulp-rename’); // Renames files E.g. style.css → style.min.css
const notify = require(‘gulp-notify’); // Sends message notification to you

// JS related plugins.
const concat = require(‘gulp-concat’); // Concatenates JS files
const uglify = require(‘gulp-uglify’); // Minifies JS files

// Paths
const paths = {
styles: {
src: ‘./src/sass//*.scss’,
dest: ‘./dist’
},
scripts: {
src: './src/js/
/*.js’,
dest: ‘./dist/js’
}
};

function styles() {

return gulp.src(paths.styles.src)
.pipe(sourcemaps.init())
.pipe(sass({outputStyle: ‘compressed’}).on(‘error’, sass.logError))
.pipe(autoprefixer({
Browserslist: [‘last 2 versions’],
cascade: false
}))
.pipe(cssnano({ zindex: false }))
.pipe(rename( { suffix: ‘.min’ }))
.pipe(sourcemaps.write(’./’))
.pipe(gulp.dest(paths.styles.dest))
.pipe( notify( { message: ‘Styles task completed!’, onLast: true, sound: ‘Frog’ } ) );
}

function scripts() {

return gulp.src(paths.scripts.src, { sourcemaps: true })
.pipe(babel({
presets: [
[’@babel/env’, {
modules: false
}]
]
}))
.pipe(concat( ‘main.js’ ) )
.pipe(rename( { suffix: ‘.min’ }))
.pipe(uglify() )
.pipe(gulp.dest(paths.scripts.dest, {sourcemaps: true}) )
.pipe(notify( { message: ‘Scripts task completed!’, onLast: true, sound: ‘Frog’ } ) );
}

function watch() {
gulp.watch(paths.styles.src, styles);
gulp.watch(paths.scripts.src, scripts);
}

exports.styles = styles;
exports.scripts = scripts;
exports.watch = watch;
exports.default = gulp.parallel(gulp.series(styles, scripts), watch);

Hi @rwaniek,

We’d need to see the source code for this. Only the Gulp config won’t be of much use.

Well, there’s not much really. It’s a boilerplate so merely an index.html. I’ve commented out all the styles and deleted js. Still no use.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
  <title>Monitoring</title>
  <!-- <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400&display=swap" rel="stylesheet"> -->
  <!-- <link rel="stylesheet" href="bootstrap/bootstrap.min.css"> -->
  <!-- <link rel="stylesheet" href="style.min.css"> -->
</head>
<body>
  <header>
    <h1 class="text-center">Howdy, lads!</h1>
  </header>
  <main>
    <p class="px-3">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Ipsa eveniet sequi saepe deserunt ad voluptate tempore aliquam fuga laboriosam aspernatur et laudantium iure, a sapiente ullam recusandae, nisi adipisci necessitatibus.</p>
  </main>
</body>
</html>

You say it is

however previously mentioned a gulp.js and package.json so it is not merely an index.html. Are you able to share you repo for testing?

Guys, it is really a boilerplate. Source files are empty, gulp is just ready to compile js and sass. I can’t share the repo, but please have a look at folder structure.

Hi @rwaniek,

You say it’s a simple website, but I’ve tested simple and framework-based websites in the CLI today, and none of those gave such an error. We’re asking for a repo so that we can reproduce this ourselves. It might be a specific case that might be throwing errors.

1 Like

Your screenshot shows you are publishing dist, and previously you said it is merely an index.html, but there is very clearly a package.json file, and node_modules directory, so you are obviously building something that outputs to the dist directory. That is why, as @hrishikesh says, we ask for the repo so that we may test things.

I’ve been writing about json.package from the very beginning. I did enclose it and as you saw, it had only dependencies needed for gulp to compile js and css. Moreover If you have a closer look at the screenshot you will see that the dist folder has got index file only and two empty folders.
The forum won’t let me enclose the zip. How do you want me to share the repo? I do not use github.

Post a link to your repo (GitHub, Bitbucket, et.al.)

Also, what version of Netlify CLI are you using?

netlify-cli/4.4.2 darwin-x64 node-v16.4.0

Thank you in advance

Hi @rwaniek,

Your setup works correctly with the last 3.x version of CLI that is 3.39.4. I’m narrowing down further to see if this was caused by some other version or if it’s something else.

EDIT: So the last working version seems to be 4.2.3. It breaks since 4.3.0. I’ll open an issue for the CLI team to investigate this. Thank you for reporting.

You could track it here:

Note: the issue was fixed in v5.0.1.

1 Like