4
votes

I am getting the following error in my Angular app after adding gulp babel to my gulp file. I need this to transpile and minify my ES6:

Cannot set property '0' of undefined

I'm thinking angular-file-saver doesn't like to babelfication.

Causing these errors:

angular.js:33 Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:

Error: [$injector:nomod] Module 'app' is not available!

enter image description here

Yet I can see the module being loaded client side:

enter image description here

Gulp Task: Note: this error only started occuring when I started piping through babel. If I remove babelminify, it produces the same error.

gulp.task('scripts-dev', () => {
  return gulp.src(paths.vendorJavascript.concat(paths.appJavascript, paths.appTemplates))
    .pipe(plugins.if(/html$/, buildTemplates()))
    .pipe(babel({
        presets: [['es2015', {modules: false}]]
    }))
    //.pipe(babelminify())
    .pipe(plugins.sourcemaps.init())
    .pipe(plugins.concat('app.js'))
    .pipe(plugins.sourcemaps.write('.'))
    .pipe(gulp.dest(paths.tmpJavascript))
    .pipe(plugins.connect.reload());
});

This error occurs even without minifying taking place

1
Any comments or help on this? - Growler
you can add ng-strict-di to your ng-app element in the HTML to have angular generate errors relating to any code that is not minification safe. Beyond that, it's possible something isn't right with your gulp task that is causing some of your scripts to not be included.... - Claies
@Claies see above, I added a picture (red text). I'm thinking angular-file-saver doesn't like to babelfication. - Growler
Did you find any solution? - MAG

1 Answers

0
votes

using

.pipe(babel({
            presets: ['es2015']
        }))
//.pipe(uglify({ mangle: false }))  gulp-ugligy is used

should serve your purpose