I have written a after_prepare hook for my Cordova build which removes the node_modules folder from the final build:
#!/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 -d
in in the CLI but upon switching to iOS it fails with the following error:
env: node\r: No such file or directory Hook failed with error code 127:
I have tried with just the reference to the ios platform folder and it issues the same error message.
You need to use a text editor like NotePad++
On NotePad++, you will follow these steps:
In the search mode, select 'Extended', and then go ahead and replace all.
Save the file and perform the iOS build again
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With