【问题标题】:Grunt build not working in Yo AngularGrunt build 在 Yo Angular 中不起作用
【发布时间】:2014-07-14 13:29:44
【问题描述】:

我用 Yo angular-generator 构建了一个 Angular 应用程序,

我正在使用 Grunt Build 构建应用程序,然后我添加了 Bootstrap 3 和 npm install grunt-bower-install

我将这些行添加到 Grunt 文件中

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'
            ],

          }
        },

我已经删除了这些行!

现在 Grunt Build 抛出这个错误

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

Aborted due to warnings.

我确实知道该做什么,甚至知道从哪里开始?

【问题讨论】:

    标签: angularjs gruntjs npm bower grunt-build-control


    【解决方案1】:

    在我的 yeoman 生成的项目中,这个任务看起来像:

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

    在较新的版本中,而不是 html 使用 src

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

    也许您可以根据自己的情况调整它。虽然我认为它应该在没有变化的情况下工作。

    但你几乎一样,所以问题可能在另一个地方。

    【讨论】:

      【解决方案2】:

      我找到了答案,

      我只需要运行 Bower Install,

      【讨论】:

      • 哈,考虑过了。
      • 只用了几天bower :)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-01
      • 2016-05-05
      • 2019-03-01
      • 2019-10-17
      • 1970-01-01
      相关资源
      最近更新 更多