简体   繁体   English

Grunt.js无法读取文件(错误代码:EISDIR)

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

My folder structure is as follows 我的文件夹结构如下:

  • static/ 静态的/
    • js/ js /
      • default/ 默认/
        • main.js main.js
      • lib/ lib /
        • someplugin.js someplugin.js
        • vendor/ 供应商/
          • jquery.js jquery.js
          • tinyMce.js tinyMce.js

Inside main.js I have the following code 在main.js内部,我有以下代码

@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: 我每次运行grunt ,我发现了follwing错误:

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. 如果我删除tinyMce.js进口线,咕噜运行良好。 So the problem must be with tinyMce, right? 所以问题一定出在tinyMce上,对吗? 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. 错了,如果我切tinyMce.js的所有内容,并将其粘贴里面的jquery.js(jquery.js和自己的内容后),咕噜将运行正常。

Here is my Gruntfile.js: 这是我的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 而是将所有文件导入main.js

why you don't let grunt do this? 为什么你不让咕unt做呢?

you can use concat and uglify for this: 您可以为此使用concat和uglify:

see: Grunt concat all package.json dependencies 请参阅: Grunt concat所有package.json依赖项

have you tried just use that cwd: 您是否尝试过仅使用该cwd:

'static/**/*.js',

also can you share your gruntfile.js? 还可以分享您的gruntfile.js吗? so I can have a better look. 这样我可以更好看

I hope that helped you. 希望对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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