简体   繁体   中英

Grunt.js Unable to read file (Error code: EISDIR)

My folder structure is as follows

  • static/
    • js/
      • default/
        • main.js
      • lib/
        • someplugin.js
        • vendor/
          • jquery.js
          • tinyMce.js

Inside main.js I have the following code

@import '../lib/vendor/jquery.js';
@import '../lib/vendor/tinyMce.js';
@import '../lib/someplugin.js';
// ... more code ...

Every time I run grunt I'm getting the follwing error:

Warning: Unable to read "/PATH_TO_MY_APP/static/js/lib/vendor" file (Error code: EISDIR).

If I remove the tinyMce.js import line, grunt runs fine. So the problem must be with tinyMce, right? Wrong, if I cut all the content of tinyMce.js and paste it inside jquery.js (after jquery.js own content), grunt will run ok.

Here is my Gruntfile.js:

module.exports = function(grunt) {

        // Project configuration.
        grunt.initConfig({
            pkg: grunt.file.readJSON('package.json'),
            import: {
                options: {},
                default: {
                    expand: true,
                    cwd: 'static/js/default/',
                    src: '**/*.js',
                    dest: 'static/js/stage/default/',
                    ext: '.js',
                }
            }
        });

        grunt.loadNpmTasks('grunt-import');
        grunt.registerTask('default', ['import']);

};

I've read the docs of the plugins I use, but I found no option that may help. :(

instead import all your files in the main.js

why you don't let grunt do this?

you can use concat and uglify for this:

see: Grunt concat all package.json dependencies

have you tried just use that cwd:

'static/**/*.js',

also can you share your gruntfile.js? so I can have a better look.

I hope that helped you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM