How do I programatically attach fields to a node defined in hook_node_info() I've got a module which defines a node type. I also need to attach a few fields to this node. 

I'm defining the node in hook_node_info(), and I'm creating fields in hook_install(). However, isn't this going to create the fields before the node? Isn't hook_install() executed before hook_node_info(), meaning that I'll be attempting to attach the fields to a non-existing node type at that point?

How do I define a node type programatically, and also attach fields to the node type programatically upon module installation?
If you have familiarize with features module. It will be easy. You can get more idea about content type creation and it is related with field. Follow the steps to get a working example. 


Create content type and related field in you site.
Enable features module and export this content type as a new module.
The system generated module, you can find the content type creation and field relateion code.
You can find documentation for creating content type and field via code in drupal.