1

I have an ionic application built using ionic V1. Everything was working fine until recently. Now this EISDIR error keeps popping up whenever I try to build it. After a lot of debugging, I found out that cordova-plugin-crypt-file was causing the issue. Because when I disable it, the project successfully Builds.

I am using Cordova crypt file plugin to encrypt my source code. I spent a lot of time trying to fix it, but sadly I couldn't do anything.

I also know that EISDIR error is due to directory issue ("Error, Is Directory") from NPM stuck giving the same error EISDIR: Illegal operation on a directory, read at error (native). But I could not find any directory issues in my project.

Also, I have seen this issue on github https://github.com/tkyaji/cordova-plugin-crypt-file/issues/39. As suggested in the question when I comment the problematic line. Everything is ok and the project Builds.

I am not sure how to debug this. Any help would be appreciated. Since the client suggested this plugin, I have been actively searching for a way to fix this. But could not find any solutions yet.

Thanks in advance.

2xSamurai
  • 1,221
  • 12
  • 18

1 Answers1

0

I have managed to solve this error myself.

The plugin gives a console log when it successfully completes encrypting a file.

I had no way to find out which file it was encrypting now (which caused the error). When I looked into the plugin files, it had a hook file called 'after_prepare.js', which console logs the files it has successfully encrypted. I then added a console log before the file encryption process start, and I was able to track down which file was causing the issue.

}).forEach(function(file) {
        console.log('file', file); // console log I added
        var content = fs.readFileSync(file, 'utf-8');
        fs.writeFileSync(file, encryptData(content, key, iv), 'utf-8');
        console.log('encrypt: ' + file);
    });

Seems it was a directory name issue. I had Chart.js installed and one of its folders was named chart.js which was causing the issue.

2xSamurai
  • 1,221
  • 12
  • 18