Skip to content
This repository has been archived by the owner on Mar 26, 2018. It is now read-only.

generator-angular error with gulp #1199

Open
aerlaut opened this issue Nov 1, 2015 · 23 comments
Open

generator-angular error with gulp #1199

aerlaut opened this issue Nov 1, 2015 · 23 comments
Labels

Comments

@aerlaut
Copy link

aerlaut commented Nov 1, 2015

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

@benjipott
Copy link

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

@dcu
Copy link

dcu commented Nov 5, 2015

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

@ernie58
Copy link

ernie58 commented Nov 9, 2015

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

@eddiemonge
Copy link
Member

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

@ww-k
Copy link

ww-k commented Nov 11, 2015

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

@ww-k
Copy link

ww-k commented Nov 11, 2015

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

@9mm
Copy link

9mm commented Nov 11, 2015

@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?

@ww-k
Copy link

ww-k commented Nov 12, 2015

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

@darknasty
Copy link

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']}))

@eddiemonge
Copy link
Member

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

@nicholasglazer
Copy link

Check this jonkemp/gulp-useref#153

@onlyskyguy
Copy link

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

@chr4ss1
Copy link

chr4ss1 commented Dec 21, 2015

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",

@ChrisPenner
Copy link

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.

@KidA001
Copy link

KidA001 commented Jan 4, 2016

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.

@szantner
Copy link

szantner commented Jan 5, 2016

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.

@eddiemonge
Copy link
Member

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

alfonso-presa added a commit to alfonso-presa/generator-angular that referenced this issue Jan 11, 2016
alfonso-presa added a commit to alfonso-presa/generator-angular that referenced this issue Jan 11, 2016
@alfonso-presa
Copy link

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 added a commit to alfonso-presa/generator-angular that referenced this issue Jan 11, 2016
@alfonso-presa
Copy link

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.

@patrikbego
Copy link

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.

@ksgupta
Copy link

ksgupta commented Jun 15, 2016

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

@andrecbr
Copy link

andrecbr commented Aug 3, 2016

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

last release: 11 Dec 2015 '¬¬

@wching
Copy link

wching commented Sep 20, 2016

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests