Cordoba after_prepare intercepts Android but does not work on iOS

I wrote an after_prepare hook for my Cordova assembly, which removes the node_modules folder from the final assembly:

#!/usr/bin/env node

/**
 * The node modules we want to remove from the build prior to building
 * @type {Array}
 */
var foldersToRemove = ["platforms/android/assets/www/node_modules", "platforms/ios/www/node_modules"];

var fse = require('fs-extra');
var path = require('path');
var rootdir = process.argv[2];

foldersToRemove.forEach(function(folder) {

    var rmFolder = path.join(rootdir, folder);

    fse.remove(rmFolder, function(err) {
        if (err) {
            return console.error(err);
        } else {
            console.log(rootdir);
            console.log("fse folder removed success!")
        }
    });

});

This works for me when I run cordova prepare android -din the CLI, but when switching to iOS it crashes with the following error:

env: node \ r: no such file or directory Hook error with error code 127:

I tried only the link to the ios platform folder and it gives the same error message.

+4
source share
3 answers

You need a text editor like NotePad ++

In NotePad ++, you follow these steps:

  • Open the file that gives you problems
  • "" ""
  • : '\ r\n'
  • \n
  • , "".
  • "", .

  • iOS

+2

OSX:

tr -d '\r' < FILE_NAME > FILE_NAME
0

Ionic Cordova OSX, , , .

0

All Articles