Angular Error Module is not available - gulp babel
See original GitHub issueMore on this issue here:
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.
Prior to adding babel
through the gulp piping, the app runs fine without error.
angular.js:33 Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to: Error: [$injector:nomod] Module ‘app’ is not available!
In the browser, I see the Angular module being loaded in the concatenated app.js:
I’m lost…
Gulp Task: Note: this error only started occurring when I started piping through babel:
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(plugins.sourcemaps.init())
.pipe(plugins.concat('app.js'))
.pipe(plugins.sourcemaps.write('.'))
.pipe(gulp.dest(paths.tmpJavascript))
.pipe(plugins.connect.reload());
});
.babelrc Configuration:
{
"presets": [
["es2015", { "modules": false }]
]
}
Expected behavior: I am using ES6 in my Angular and need to transpile it, and eventually minify it. It transpiles and minifies without any gulp errors as expected, but throws the Angular error above in browser. We have an existing gulp file so I thought using gulp-babel
would be an easy transition.
Possible solution: I saw “use strict” being prepended to the app.js output file, and thought that may have been screwing things up. I’ve applied modules: false
to presets which successfully stops the prepending. This did not fix it. Angular isn’t providing any other useful tips so I come to you.
My environment:
software | version |
---|---|
Babel | “gulp-babel”: “^6.1.2”, |
node | node -v: v7.1.0 |
npm | npm -v: 3.10.9 |
Operating System | OSX Yosemite 10.10.5 |
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:6 (1 by maintainers)
Top GitHub Comments
finally i did this.
I’m triaging old issues on gulp-babel. Since this has been inactive for ages, I’m going to close it. Feel free to re-open if there’s still something to discuss, but I’m assuming at this point it’s been too long to address in a useful way.