TypeError when trying to run an application on Android using Windows 10

When trying to use the ionic run Android command on my Windows 10 machine, I receive the following error;

net.js:653
throw new TypeError(
^

TypeError: Invalid data, chunk must be a string or buffer, not object
at Socket.write (net.js:653:11)
at Object. (C:\Projects***********************\hooks\after_prepare\010_add_platform_class.js:90:22)
at Module._compile (module.js:570:32)
at Object.Module._extensions…js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)

Error: Hook failed with error code 1: C:\Projects***********************\hooks\after_prepare\010_add_platform_class.js

Are there any suggestions on how to fix this issue? It doesn’t seem to affect colleagues that are using Windows 7 machines.

I found a related issue, bug: Can create and build cordova but ionic troughs hooks error · Issue #417 · ionic-team/ionic-cli · GitHub. The suggested “solution” is to rename the after-prepare folder. I am new to Ionic, so I’m not sure what the impact of this rename will be on the application, and I am not sure if there is something else that I should be doing to fix this issue.

Renaming the folder does “fix” the issue, but it seems like this could cause issues in other areas.

1 Like

I had this same error although I was building for iOS. After futilely trying to debug it, I resorted to my standard fix: I restarted fresh by creating a new project and moving my /src/ and various config files over to it. The problem did not reoccur in the new project.