Grunt build not working in Yo Angular

和自甴很熟 提交于 2019-12-14 03:55:37

问题


I build a Angular App with Yo angular-genertor,

I was building the app with Grunt Build fine, then I added Bootstrap 3 and also npm install grunt-bower-install

I added these lines to the Grunt file

module.exports = function (grunt) {


  require('load-grunt-tasks')(grunt);

  require('time-grunt')(grunt);

  //ADDED THIS LINE
  grunt.loadNpmTasks('grunt-bower-install');

  grunt.initConfig({

    yeoman: {
      // configurable paths
      app: require('./bower.json').appPath || 'app',
      dist: 'dist'
    },
     //ADDED THESE LINES
    'bower-install': {
        target: {
            src: [
              'app/index.html'
            ],

          }
        },

I have removed these line however!

Now Grunt Build is throwing this error

Running "bowerInstall:app" (bowerInstall) task
Warning: Cannot read property 'main' of undefined Use --force to continue.

Aborted due to warnings.

I do know what to do or even where to start?


回答1:


In my yeoman generated project this task looks like:

'bower-install': {
  app: {
    html: '<%= yeoman.app %>/index.html',
    ignorePath: '<%= yeoman.app %>/'
  }
},

In newer version instead of html uses src:

'bowerInstall': {
  app: {
    src: ['<%= yeoman.app %>/index.html'],
    ignorePath: '<%= yeoman.app %>/'
  }
},

Maybe you adapt it to your case. Though i think it should work without changes.

But you have almost the same, so maybe the problem in another place.




回答2:


I found the answer,

I simply needed to run Bower Install,



来源:https://stackoverflow.com/questions/23858858/grunt-build-not-working-in-yo-angular

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!