A new method is proposed to compute the eigenpairs of a parameter‐dependent nonlinear eigenvalue problem. We first analyze the properties on the analytic perturbation of the invariant pair of a nonlinear eigenvalue problem and provide a method to compute the first‐order and high‐order derivatives of the invariant pair. On these grounds, the subspaces independent of the parameter and containing the approximations to the desired eigenvectors of a nonlinear eigenvalue problem are constructed. Then the desired eigenpairs of a nonlinear eigenvalue problem are obtained by projecting the parameter‐dependent nonlinear eigenvalue problem to the generated subspaces. The errors of the computed eigenpairs are estimated. Finally, the efficiency of the proposed method is illustrated with some numerical examples.