Reputation: 1060
I'm new to Browserify and I'm trying to setup a project with it and Angular 1.5.3. I am getting the following error when I view my site:
Uncaught TypeError: angular.module is not a function
Stepping through the code I can see that in my line below, angular is an empty object:
var angular = require("./../bower_components/angular/angular.js");
Here is my gulpfile.js:
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
//the core bundle for our application
gulp.task('default', function() {
return browserify('app/app.js')
.bundle()
.pipe(source('app.js'))
.pipe(gulp.dest('build/js'));
});
Upvotes: 1
Views: 73
Reputation: 2704
I installed angular using npm instead of bower when I started using browserify. Then I was able to say:
import angular from 'angular';
and it works fine. I believe you can use bower still, but you might need to use debowerify. I'm not certain- too much of the browserify process is still kind of magic to me, and needs unpacking.
Upvotes: 1