The nanobubbles contained in the human body are induced to collapse by the shock wave, and thus produce a strong impact and high-speed nanojet, resulting in trauma to human tissues. The collapse of nanobubbles in water caused by shock waves is investigated by molecular dynamics. Nanobubbles are divided into three types: vacuum nanobubble, carbon dioxide nanobubble, and oxygen nanobubble. The influence of factors such as the number of gas molecules, the diameter of the nanobubbles, and the impulse of the shock wave on the bubble collapse are considered separately. The results show that the addition of gas molecules to vacuum nanobubbles does not affect the propagation of shock waves. However, before the nanobubbles are completely collapsed, the maximum velocity of the nanojet formed by the collapse of nanobubbles containing 718 carbon dioxide molecules (or 733 oxygen molecules) is larger than that of vacuum and nanobubbles containing 1368 carbon dioxide molecules (or 1409 oxygen molecules). After the nanobubbles are completely collapsed, the gas molecules cause the velocity of the nanojet to decay, and finally the maximum velocity of the nanojet containing gas molecules is less than that of the vacuum nanojet. In addition, it is also found that the collapse time of nanobubbles is short at high impulse, and the density and pressure when the shock wave passes at the same time are both greater. After the bubble collapses, the maximum velocity of the nanojet is larger, and the impact force is much stronger than that at a small impulse. Larger diameter nanobubble has a longer collapse time, and the density and pressure when the shock wave passes at the same time are both smaller, and the shock wave propagation is slower, but the maximum speed of the nanojet is larger. The impact is stronger. The greater the maximum velocity of the nanojet, the greater the distance that is dispersed by the gas molecules of the gas-containing nanobubbles in the impact direction will be and the deeper the depression.