Hi @beingchiragsharma,
The error message hints that (at least one) of your input columns is a factor with only 1 level. You need to check the input data to find the culprit and exclude it from the regression.
# Works OK
data(mtcars)
lm(disp~. ,data=mtcars) -> mod1
# Create an additional factor with only one level
mtcars$non_var <- as.factor(c(5))
str(mtcars)
lm(disp~. ,data=mtcars) -> mod1
# Error in contrasts<-(*tmp*, value = contr.funs[1 + isOF[nn]]) :
# contrasts can be applied only to factors with 2 or more levels
HTH