Nanotechnology has an impact on our lives in a many ways, from better medical treatments and more efficient energy sources to stronger and lighter materials and advanced electronics and this article presents the implementation of a perturbation method for the vibration analysis of simply supported and clamped–clamped Euler–Bernoulli nanobeams resting on nonlinear elastic foundations in thermal environment using nonlocal elasticity theory. Hamilton's principle is used to construct the differential equation of motion of a nanobeam in conjunction with appropriate boundary conditions. The equations of motion of the Euler–Bernoulli nanobeam are determined using nonlocal elasticity theory. It is shown how thermal loadings affect the vibration of the Euler–Bernoulli nanobeam. The multiple scale method, which is one of the perturbation method, is used to get an approximated solution for the presented system. The effects of temperature, Winkler, Pasternak and nonlinear foundation parameters on the vibration analysis of simply supported and clamped–clamped nanobeams are determined and results are given in tables and graphs.