Crown ethers, as a kind of heterocycle, have been the subject of great interest over recent decades due to their selective capability to bind to metal cations. The use of a constant crown ether, such as naphtho-15-crown-5 (N15C5), and varied metal cations (Li, Na, K, Be, Mg, Ca, Co, Ni, Cu) makes it possible to determine the contributions of the metal cations to nonlinear optical (NLO) responses and to design an appropriate NLO-based cation detector. N15C5 and its metal cation derivatives have been systematically investigated by density functional theory. It is found that the dependency of the first hyperpolarizability relies on the metal cation, especially for transition metals. The decrease of the first hyperpolarizabilities for alkali metal cation derivatives is due to their relatively low oscillator strengths, whereas the significant increase of the first hyperpolarizabilities for transition metal cation derivatives can be further illustrated by their low transition energies, large amplitudes and separate distributions of first hyperpolarizability density. Thus, the alkali metal and transition metal cations are distinguishable and the transition metal cations are easier to detect by utilizing the variations in NLO responses.