Rapid drug detection is vital for combating drug abuse and inhibiting transmission, and the emergence of various novel psychoactive substances (NPS) has placed higher demands on field testing. To establish a rapid, nondestructive, and accurate analytical and classification method for testing novel psychoactive substances, shifted-excitation Raman difference spectroscopy (SERDS) was used to detect 37 NPS including fentanyl, amphetamine, and synthetic cannabinoid under the experimental conditions of laser light source (785 and 785.5 nm). SERDS was also used in conjunction with machine learning to find the best classification prediction model. In this study, the characteristic peaks of 37 NPS analogs were extracted, and the characteristic peaks were attributed to the structures of the substances. We compared the classification effects of Support Vector Machine (SVM), K-NearestNeighbor (KNN), ensemble classifier, neural network, tree, naive Bayes, and discriminant analysis and provided three hyperparametric optimization methods. Finally, the cross-validation accuracy of SVM under BOA optimization is 97.3%, which can well distinguish three families of samples. The ability of SERDS to resist strong fluorescence interference makes it a powerful tool for on-site analysis of NPS. In this study, we have given 37 unreported standard Raman peaks of NPS and three seized samples, which can be used as a reference. Shifted-excitation differential Raman spectroscopy combined with machine learning can effectively provide solutions for customs, health care, on-site police, large event security, and trace evidence inspection.