ERRORS

[error] connection error: MongoParseError: option usecreateindex is not supported

gorae_lulu 2023. 8. 30. 11:33

 

❗ 에러상황

mongoose.connect("mongodb://localhost:27017/go-camp", {
  useNewUrlParser: true,
  useCreateIndex: true,
  useUnifiedTopology: true,
});

에러발생.

 

✅ 해결방안

No More Deprecation Warning Options

useNewUrlParser, useUnifiedTopology, useFindAndModify, and useCreateIndex are no longer supported options. Mongoose 6 always behaves as if useNewUrlParser, useUnifiedTopology, and useCreateIndex are true, and useFindAndModify is false. Please remove these options from your code.

몽구스 공식문서를 보니 버전6부터 해당 옵션을 사용하지 않아도 되는 것같다. 그래서 지워주니 잘 작동하였다.