Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Cannot read property 'files' of undefined #548

Open
zeroerrequattro opened this issue Oct 16, 2017 · 4 comments
Open

Fatal error: Cannot read property 'files' of undefined #548

zeroerrequattro opened this issue Oct 16, 2017 · 4 comments

Comments

@zeroerrequattro
Copy link

I use grunt watch with the following modules to minify the code in my website:

  • grunt-contrib-uglify
  • grunt-contrib-compass
  • grunt-contrib-htmlmin

Everytime I launch grunt watch and modify some file, i got this error:

Fatal error: Cannot read property 'files' of undefined

Even with grunt watch --verbose I don't get any other useful info than the error
If I launch the tasks separately (eg. grunt uglify) they work with no problems.

Here's the package.json:

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    htmlmin: {
      build: {
        options: {
          removeComments: true,
          collapseWhitespace: true,
          ignoreCustomFragments: [
            /\{\{[\s\S](.*?)\}\}/,
            /\{\%[\s\S](.*?)\%\}/,
            /<\?[\s\S]*?\?>/
          ]
        },
        files: [
          {
            expand: true,
            cwd: 'dev/html/layout',
            src: ['*.html'],
            dest: 'theme/layout',
            ext: '.liquid',
            extDot: 'last'
          },
          {
            expand: true,
            cwd: 'dev/html/snippets',
            src: ['*.html'],
            dest: 'theme/snippets',
            ext: '.liquid',
            extDot: 'last'
          },
          {
            expand: true,
            cwd: 'dev/html/templates',
            src: ['*.html'],
            dest: 'theme/templates',
            ext: '.liquid',
            extDot: 'last'
          }
        ]
      }
    },
    uglify: {
      options: {
        mangle: false,
        //banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */'
      },
      dest: {
        files: {
          'theme/assets/vendors.min.js': [
            'dev/js/vendor/jquery.min.js',
            'dev/js/vendor/bootstrap.min.js',
            'dev/js/vendor/jquery.scrollto.js',
            'dev/js/vendor/owl.carousel.min.js',
            'dev/js/vendor/waypoint.min.js'
          ],
          'theme/assets/function-data.min.js.liquid': [ 'dev/js/function-data.js' ],
          'theme/assets/function-effect.min.js.liquid': [ 'dev/js/function-effect.js' ],
          'theme/assets/related-items.min.js.liquid': [
            'dev/js/related-items.js'
          ],
          'theme/assets/function-countries.min.js.liquid': [
            'dev/js/function-countries.js'
          ]
        }
      }
    },
    compass: {
      dist: {
        options: {
          config: 'compass.rb',
          outputStyle: 'compressed',
          environment: 'production',
          specify: [
            'dev/scss/account.scss',
            'dev/scss/cart.scss',
            'dev/scss/checkout.scss',
            'dev/scss/collections.scss',
            'dev/scss/home.scss',
            'dev/scss/landings.scss',
            'dev/scss/main.scss',
            'dev/scss/page-freelancer.scss',
            'dev/scss/page-shop-instagram.scss',
            'dev/scss/page-special-collection01.scss',
            'dev/scss/page-static.scss',
            'dev/scss/page-weddings.scss',
            'dev/scss/product.scss',
            'dev/scss/referral.scss'
          ],

          relativeAssets: false,
          noLineComments: false,
          sourcemap: false
        }
      }
    },
    watch: {
      sass: {
        files: ['dev/scss/**'],
        tasks: ['compass']
      },
      js: {
        files: ['dev/js/**'],
        tasks: ['uglify']
      },
      html: {
        files: ['dev/html/**'],
        tasks: ['htmlmin']
      }
    }
  });

  // Load the plugins that provides the tasks.
  grunt.loadNpmTasks('grunt-contrib-htmlmin');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-compass');
  grunt.loadNpmTasks('grunt-contrib-watch');

  // Default task(s).
  grunt.registerTask('default', ['watch']);
  grunt.registerTask('build', ['compass','uglify','htmlmin']);
};

Here's the environment I'm working with:
MacOS 10.12.6
node@8.6.0
npm@5.4.2

@zeroerrequattro
Copy link
Author

Any news?

@zeroerrequattro
Copy link
Author

Did I set something wrong?
Is something related to some other module?
Is this module deprecated?

@zeroerrequattro
Copy link
Author

Somebody can please help me with this?
It's almost 4 months and nobody told me anything.

I updated the system, reinstalled the modules but the problem persist, I keep receiving the message:

Fatal error: Cannot read property 'files' of undefined

The environment is:
MacOS 10.13.3
node@v8.7.0
npm@5.6.0

@starryeyez024
Copy link

I am getting the same error :(

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

No branches or pull requests

2 participants