3

I have imported an existing Ionic app into VS 2015 Update 1. I'm using the latest Tools for Apache Cordova Update 7. When I build the app, I'm getting the errors below when it tries to execute the hooks\after_prepare\010_add_platform_class.js file. If I remove the file, VS will build and execute the app fine. Is this a bug in TACO or am I doing something wrong?

Executing "after_prepare"  hook for all plugins.
1>  Running command: "C:\Program Files (x86)\nodejs\node.exe" D:\SampleApp\hooks\after_prepare\010_add_platform_class.js D:\SampleApp
1>MSBUILD : cordova-build error : net.js:633
1>  net.js:633
1>MSBUILD : cordova-build error :  throw new TypeError('invalid data');
1>      throw new TypeError('invalid data');
1>MSBUILD : cordova-build error :  ^
1>            ^
1>MSBUILD : cordova-build error : TypeError: invalid data
1>  TypeError invalid data
1>MSBUILD : cordova-build error :  at Socket.write (net.js:633:11)
1>      at Socket.write (net.js:633:11)
1>MSBUILD : cordova-build error :  at Object.<anonymous> (D:\SampleApp\hooks\after_prepare\010_add_platform_class.js:90:22)
1>      at Object.<anonymous> (D:\SampleApp\hooks\after_prepare\010_add_platform_class.js:90:22)
1>MSBUILD : cordova-build error :  at Module._compile (module.js:460:26)
1>      at Module._compile (module.js:460:26)
1>MSBUILD : cordova-build error :  at Object.Module._extensions..js (module.js:478:10)
1>      at Object.Module._extensions..js (module.js:478:10)
1>MSBUILD : cordova-build error :  at Module.load (module.js:355:32)
1>      at Module.load (module.js:355:32)
1>MSBUILD : cordova-build error :  at Function.Module._load (module.js:310:12)
1>      at Function.Module._load (module.js:310:12)
1>MSBUILD : cordova-build error :  at Function.Module.runMain (module.js:501:10)
1>      at Function.Module.runMain (module.js:501:10)
1>MSBUILD : cordova-build error :  at startup (node.js:129:16)
1>      at startup (node.js:129:16)
1>MSBUILD : cordova-build error :  at node.js:814:3
1>      at node.js:814:3
1>  Command finished with error code 1: C:\Program Files (x86)\nodejs\node.exe D:\SampleApp\hooks\after_prepare\010_add_platform_class.js,D:\SampleApp
1>MSBUILD : cordova-build error : Error: Hook failed with error code 1: D:\SampleApp\hooks\after_prepare\010_add_platform_class.js
1>  Error Hook failed with error code 1: D:\SampleApp\hooks\after_prepare\010_add_platform_class.js
Ionian316
  • 2,303
  • 2
  • 28
  • 36
  • I work on the Tools for Apache Cordova team at Microsoft. Right now, we're investigating ways to make it easier for developers to recover from build errors in VS. I’m hoping to chat with folks like you who have encountered build errors and reached out to the community for troubleshooting. Customer feedback is the number one way we make product design decisions, so I’d love it if you could make time for a 20min phone call this week or next to talk about how you understand and overcome build issues. rsalva [at] Microsoft [dot] com – Ryan J. Salva Apr 08 '16 at 17:54

2 Answers2

9

This can happen if you're building in a project where your files are locked as read-only (for example, when using TFS source control). Upon build, there is a script used by Ionic to modify the home page of your app to add a CSS class that identifies your target platform. If your home page file (e.g. index.html) is marked as read only, try clearing that setting and build again.

Jordan Matthiesen
  • 1,480
  • 7
  • 17
  • That was exactly it. Checking out **index.html** did indeed make the file run. So not obvious. Thanks for your help. – Ionian316 Apr 01 '16 at 15:14
0

are you deploying to Ripple when you get this error? Does this happen when you build a blank project to local machine? Try deleting the platforms folder and rebuilding.

Linda Z
  • 312
  • 1
  • 5
  • It doesn't matter if I deploy to Ripple or the VS Android Emulator. Deleting the platforms folder and rebuilding did not help either. – Ionian316 Mar 29 '16 at 19:13