Cordova after_prepare hook succeeds in Android but fails in iOS
android, build, cordova, ios, node.js
Solution
You need to use a text editor like NotePad++
On NotePad++, you will follow these steps:
- Open the file thats giving you issues
- Go to 'Find' option and select the 'Replace' tab
- You should find this string : '\r\n'
- Replace it with \n
- Make sure the 'wrap around' option is selected.
In the search mode, select 'Extended', and then go ahead and replace all.
Save the file and perform the iOS build again
Problem
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.