  We report the first hard X-ray (3-79 keV) observations of the millisecond
pulsar (MSP) binary PSR J1023+0038 using NuSTAR. This system has been shown
transiting between a low-mass X-ray binary (LMXB) state and a rotation-powered
MSP state. The NuSTAR observations were taken in both LMXB state and
rotation-powered state. The source is clearly seen in both states up to ~79
keV. During the LMXB state, the 3-79 keV flux is about a factor of 10 higher
that in the rotation-powered state. The hard X-rays show clear orbital
modulation during the X-ray faint rotation-powered state but the X-ray orbital
period is not detected in the X-ray bright LMXB state. In addition, the X-ray
spectrum changes from a flat power-law spectrum during the rotation-powered
state to a steeper power-law spectrum in the LMXB state. We suggest that the
hard X-rays are due to the intra-binary shock from the interaction between the
pulsar wind and the injected material from the low-mass companion star. During
the rotation-powered MSP state, the X-ray orbital modulation is due to Doppler
boosting of the shocked pulsar wind. At the LMXB state, the evaporating matter
of the accretion disk due to the gamma-ray irradiation from the pulsar stops
almost all the pulsar wind, resulting the disappearance of the X-ray orbital
modulation.
