Physics-informed neural networks (PINNs) are employed to solve the classical compressible flow problem in a converging–diverging nozzle. This problem represents a typical example described by the Euler equations, a thorough understanding of which serves as a guide for solving more general compressible flows. Given a geometry of the channel, analytical solutions for the steady states do indeed exist, and they depend on the ratio between the back pressure of the outlet and the stagnation pressure of the inlet. Moreover, in the diverging region, the solution may branch into subsonic flow, supersonic flow, or a mixture of both with a discontinuous transition where a normal shock occurs. Classical numerical schemes with shock fitting and capturing methods have been developed to solve this type of problem effectively, whereas the original PINNs are unable to predict the flows correctly. We make a first attempt to exploit the power of PINNs to solve this problem directly by adjusting the weights of different components of the loss function to acquire physical solutions and in the meantime, avoid trivial solutions. With a universal setting yet no exogenous data, we are able to solve this problem accurately; that is, for different given pressure ratios, PINNs provide different branches of solutions at both steady and unsteady states, some of which are discontinuous in nature. For an inverse problem such as unknown specific-heat ratio, it works effectively as well.