Photoperiod plays an important role in the growth, development, and metabolism of crustaceans. The growth and reproduction of crabs are closely related to the photoperiod. The hepatopancreas is an important source of innate immune molecules; however, hepatopancreatic patterns of gene expression depending on the photoperiod—which may underlie changes in immune mechanisms—remain unknown. To study the molecular basis of immune regulation in the Chinese mitten crab (Eriocheir sinensis) under different light conditions, a new generation of high-throughput Illumina sequencing technology was used, and functional genes associated with immune function in the hepatopancreas of this crab were explored via assembly of high-quality sequences, gene annotation, and classification. A total of 383,899,798 clean reads from the hepatopancreas of the normal group (12 h/12 h L:D), 387,936,676 clean reads from the continuous light group (24 h/0 h L:D), and 384,872,734 clean reads from the continuous darkness group (0 h/24 h L:D) were obtained. Compared with the normal group, 141, 152, 60, 87, 90, and 101 differentially expressed genes were identified in the groups exposed to continuous light for 2 days, continuous darkness for 2 days, continuous light for 4 days, continuous darkness for 4 days, continuous light for 6 days, and continuous darkness for 6 days, respectively. The results of this study revealed that under continuous light and dark conditions, the crabs were most affected by light on day 2, but the interference gradually decreased with time. We suggest that long-term light or dark treatment makes crabs adaptable to fluctuations in the photoperiod. The expression of genes associated with immune response patterns was found to change during different photoperiods. Prophenoloxidase (proPO) and serine proteinase (kazal-type serine proteinase inhibitor 1 and serine proteinase inhibitor-3) in the proPO-activating system were significantly upregulated in the 2-day continuous light group. Glutathione peroxidase 3 was significantly downregulated under continuous light exposure, while cyclooxygenase was upregulated in the continuous light and dark environments. These results provide insights into the molecular mechanism underlying the effects of the photoperiod on immune regulation and the physiological activity of E. sinensis.