question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Angular Error Module is not available - gulp babel

See original GitHub issue

More 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!

screen shot 2016-11-26 at 12 06 20 pm

In the browser, I see the Angular module being loaded in the concatenated app.js:

screen shot 2016-11-26 at 12 31 17 pm

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:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
harellevycommented, Apr 18, 2017

finally i did this.

  .pipe(useref())
  .pipe(gulpif('*.js', ngAnnotate()))
  .pipe(gulpif('*.js',babel({
      compact: false,
      presets: [['es2015', {modules: false}]]
  })))
  .pipe(gulpif('*.js', uglify({ compress: false }).on('error', function(err) {
      gutil.log(gutil.colors.red('[Error]'), err.toString());
      this.emit('end');
  })))
  .pipe(gulp.dest('./'));
0reactions
loganfsmythcommented, Sep 3, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular module not available with Gulp Babel - Stack Overflow
I am getting the following error in my Angular app after adding gulp babel to my gulp file. I need this to transpile...
Read more >
Angular Module Not Available With Gulp Babel - ADocLib
Error : injector:nomod. Module Unavailable Module '{0}' is not available! You either misspelled the module name or forgot to load it. If registering...
Read more >
babel-loader - npm
Start using babel-loader in your project by running `npm i babel-loader` ... if no node_modules folder could be found in any root directory....
Read more >
Module not found. "@babel/runtime/helpers/builtin ...
Coding example for the question Module not found. "@babel/runtime/helpers/builtin/classCallCheck" can't be resolved-babel.js.
Read more >
A complete toolchain for AngularJs - Gulp, Browserify, Sass
Although ES6 modules will be the solution of choice for Angular, ... It seems like it does reload however I get a page...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found