I am using gulp to compile my assets, however facing the following error during my build about block-scoped declarations. I don't get this error on my local machine and haven't a clue why this is happening
+ gulp build
/opt/atlassian/pipelines/agent/build/node_modules/gulp-sass/index.js:66
let sassMap;
^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:414:25)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/opt/atlassian/pipelines/agent/build/gulpfile.js:4:12)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
Here is my build yml file
# This is a sample build configuration for JavaScript.
# Check our guides at https://confluence.atlassian.com/x/14UWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: atlassian/default-image
pipelines:
branches:
master:
- step:
caches:
- node
script: # Modify the commands below to build your repository.
- ls -al
- node -v
- npm install
- npm install -g gulp
- npm install -g gulp-cli
- npm install -g bower
- gulp build
And here is my gulpfile.js
const gulp = require('gulp'),
sass = require('gulp-sass'),
plumber = require('gulp-plumber'),
notify = require('gulp-notify'),
browserSync = require('browser-sync').create(),
runSequence = require('run-sequence'),
del = require('del'),
purgecss = require('gulp-purgecss'),
sourcemaps = require('gulp-sourcemaps');
// compile sass files
gulp.task('styles', function () {
return gulp.src('styles/main.scss')
.pipe(plumber({ errorHandler: function(err) {
// show error
notify.onError({
title: "Gulp error in " + err.plugin,
message: err.toString()
})(err);
}}))
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(purgecss({
content: ['**/*.php']
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('styles/'));
});
// delete the dist folder
gulp.task('clean', function () {
return del(['dist']);
});
// create dist folder
gulp.task('create-dist-folder', function() {
return gulp.src([
'images/*.*',
'partials/*.*',
'styles/*.css',
'work/*.php',
'.htaccess',
'*.php',
'*.ico'], {base: '.'})
.pipe(gulp.dest('dist'));
});
// clean existing dist folder, rebuild stylesheet and re-create dist folder
gulp.task('build', function (callback) {
runSequence('clean', 'styles', 'create-dist-folder', callback);
});
So after some digging around, I discovered the image I was using contained an older version of node,
atlassian/default-image
The default image with no version specified so it was using version 1 by default which contained node 4.2.1. The minimum required by my project was 6. So by specifying in the yml file to use version 2 like so meant version 8.94 would be used.
atlassian/default-image:2
To see which versions of software are in the image click this link https://hub.docker.com/r/atlassian/default-image/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.