generator-angular icon indicating copy to clipboard operation
generator-angular copied to clipboard

generator-angular error with gulp

Open aerlaut opened this issue 9 years ago • 23 comments

When using Gulp with angular-generator I received error : task 'wiredep' is not in you gulpfile

I tried running the build using gulp and received error : TypeError: $.useref.restore is not a function

aerlaut avatar Nov 01 '15 10:11 aerlaut

try replace .pipe($.useref.restore()) by .pipe($.useref.assets().restore())

benjipott avatar Nov 05 '15 11:11 benjipott

@benjipott that works but gulp bower still doesn't.

dcu avatar Nov 05 '15 14:11 dcu

if you change the .bowerrc file to look for the bower_components inside the app folder gulp bower works

ernie58 avatar Nov 09 '15 12:11 ernie58

bowerrc doesnt specify where to look for the components; it specifies where to place them. we moved them out of the app folder so there is something else going on

eddiemonge avatar Nov 09 '15 19:11 eddiemonge

I replace directory: yeoman.app + './bower_components', by directory: 'bower_components', then gulp bower works

ww-k avatar Nov 11 '15 06:11 ww-k

gulp.task('bower', function () {
  return gulp.src(paths.views.main)
    .pipe(wiredep({
      directory: 'bower_components',
      ignorePath: '..'
    }))
  .pipe(gulp.dest(yeoman.app));
});

replace all task code

ww-k avatar Nov 11 '15 06:11 ww-k

@kevinwon1985 that seems to work except now angular isnt found in my project when i do gulp serve, is there something else i have to do?

9mm avatar Nov 11 '15 18:11 9mm

@9mm try this repository to instead your generator-angular, I has work on this bugs recently, and pull request, but not merged yet now.

ww-k avatar Nov 12 '15 08:11 ww-k

I am getting a similar error that @aerlaut reported. When I build with gulp I receive an error that reads:

$.useref.assets is not a function

Here is the code referenced in the error:

.pipe($.useref.assets({searchPath: [yeoman.app, '.tmp']}))

darknasty avatar Nov 16 '15 02:11 darknasty

Try using the master branch from here and see if that works

eddiemonge avatar Nov 16 '15 20:11 eddiemonge

Check this https://github.com/jonkemp/gulp-useref/issues/153

nicholasglazer avatar Nov 27 '15 17:11 nicholasglazer

What's going on with this? Can't find bower files... is this a useref problem?

onlyskyguy avatar Dec 19 '15 00:12 onlyskyguy

gulp-useref v3 does not have assets() function, and "philosophy" is a bit different.

In order to fix this, you have to re-write whatever code you have (Info from here: https://www.npmjs.com/package/gulp-useref see bottom, how TO),

OR

just make sure that you are using older version of gulp-useref, in your packages.json:

"gulp-useref": "~1.1.1",

chr4ss1 avatar Dec 21 '15 20:12 chr4ss1

Is this being patched in a new version? I just started using Yeoman, did a fresh install of yeoman, npm, bower, and generator-angular and I ran into the same issues, gulp bower fails, I changed the gulpfile to point to directory: 'bower_components', and now gulp_bower works, but angular is still undefined in the project.

ChrisPenner avatar Jan 02 '16 20:01 ChrisPenner

I'm still having issues as well, same story as @ChrisPenner @ChrisEelmaa I changed my packages.json to use "gulp-useref": "~1.1.1" but angular is still undefined.

I also made the change that @kevinwon1985 mentioned, it fixed gulp bower but again angular is still undefined when I try and run the application.

I was hoping to build a new application at work using gulp and yeoman but I might have to move another way. Would appreciate any insight.

KidA001 avatar Jan 04 '16 20:01 KidA001

Hi, I made the followings and now gulp serve seems to work fine:

  • in the .bowerrc file I changed: "directory": "bower_components" to "directory": "app/bower_components"
  • deleted the bower_components folder
  • rerun bower install
  • in the gulpfile.js around the 146th line in gulp.task('bower', function () { I changed: .pipe(gulp.dest(yeoman.app + '/views')); to .pipe(gulp.dest(yeoman.app));

The problem was not only that the gulpfile referenced the bower_components in the wrong folder, but that the index file was modified, but was created in the views folder. I am not sure that it will solve all the problems, but gulp serve works.

szantner avatar Jan 05 '16 18:01 szantner

bower_components should not be in /app since that is for your application files, not 3rd party files.

eddiemonge avatar Jan 05 '16 20:01 eddiemonge

Just uploaded a PR with solves this almost the way @szantner did but with out modifying the location of the bower_components folder (with as explained by @eddiemonge is not a good practice). I had to modify also the bower task to point to the bower_components folder correctly and also removing the ../bower_components prefix from imported filed and thus, had to modify the start:server and start:server:test to serve also the bower_components folder.

alfonso-presa avatar Jan 11 '16 10:01 alfonso-presa

It turned out my first approach broke the main build process... I now changed it so that serve tasks use a middleware to serve the bower_components folder, that is much safer also.

alfonso-presa avatar Jan 11 '16 12:01 alfonso-presa

1st issue, yeoman build is referring to gulp wiredep not gulp bower: rename gulp.task('bower', function () ...to { gulp.task('wiredep', function () { ... 2nd issue is that bower libs are not in the directory: yeoman.app + '/bower_components', but in directory: 'bower_components', 3rd issue .pipe(gulp.dest(yeoman.app + '/views'));is not in the views folder but the .pipe(gulp.dest(yeoman.app ));

So long story short, replace gulp.task('bower', function ...with: gulp.task('wiredep', function () { return gulp.src(paths.views.main).pipe(wiredep({ directory: 'bower_components', ignorePath: '..' })).pipe(gulp.dest(yeoman.app)); }); Delete the dist folder, run gulp wiredep, gulp and gulp serve or add wiredep task to the build one.

Hope this clarifies it.

patrikbego avatar Mar 18 '16 00:03 patrikbego

The question has been discussed here for any future references: http://stackoverflow.com/a/36073950/1242321

ksgupta avatar Jun 15 '16 08:06 ksgupta

ok, have many fixes, but officially (from Yeoman) nothing??

last release: 11 Dec 2015 '¬¬

andrecbr avatar Aug 03 '16 16:08 andrecbr

check @ksgupta's stackoverflow link to get the bug free gulpfile! 💯 💯

wching avatar Sep 20 '16 06:09 wching