Gulp Babel不提供角度模块

时间:2022-08-14 20:29:29

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:

在我的gulp文件中添加gulp babel之后,我的Angular应用程序中出现以下错误。我需要这个来转换和缩小我的ES6:

Cannot set property '0' of undefined

无法设置未定义的属性“0”

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

我认为角文件保护程序不喜欢babelfication。

Causing these errors:

导致这些错误:

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

angular.js:33未捕获错误:[$ injector:modulerr]由于以下原因无法实例化模块应用程序:

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

错误:[$ injector:nomod]模块'app'不可用!

Gulp Babel不提供角度模块

Yet I can see the module being loaded client side:

但我可以看到模块正在加载客户端:

Gulp Babel不提供角度模块

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

Gulp任务:注意:当我开始穿过babel时,这个错误才开始出现。如果我删除babelminify,它会产生相同的错误。

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 个解决方案

#1


0  

using

运用

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

should serve your purpose

应该服务于你的目的

#1


0  

using

运用

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

should serve your purpose

应该服务于你的目的