Reputation: 7753
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.
Upvotes: 7
Views: 3661
Reputation: 331
This error can be caused while trying to build your Ionic or Cordova application under OSX and it is most likely due to the line ending format in the file in question. Try this
Upvotes: 0
Reputation: 2877
Try this in the terminal on OSX:
tr -d '\r' < FILE_NAME > FILE_NAME
Upvotes: 0
Reputation: 168
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
Upvotes: 3