To check what version of Mongoose you are using in Node.js, print out the
mongoose.version property as follows.
const mongoose = require('mongoose'); console.log(mongoose.version); // '7.x.x'
We recommend printing the Mongoose version from Node.js, because that better handles cases where you have multiple versions of Mongoose installed.
You can also execute the above logic from your terminal using Node.js'
-e flag as follows.
# Prints current Mongoose version, e.g. 7.0.3 node -e "console.log(require('mongoose').version)"
You can also get the installed version of the Mongoose npm package using
$ npm list mongoose test@ /path/to/test └── email@example.com
npm list is helpful because it can identify if you have multiple versions of Mongoose installed.
Other package managers also support similar functions: