Automattic/mongoose · error · TypeError
Schema for array path `${path}` is from a different copy of
Error message
Schema for array path `${path}` is from a different copy of the Mongoose module. Please make sure you're using the same version of Mongoose everywhere with `npm list mongoose`. If you are still getting this error, please add `new Schema()` around the path: ${path}: new Schema(...) What it means
Error "Schema for array path `${path}` is from a different copy of the Mongoose module. Please make sure you're using the same version of Mongoose everywhere with `npm list mongoose`. If you are still getting this error, please add `new Schema()` around the path: ${path}: new Schema(...)" thrown in Automattic/mongoose.
Source
Thrown at lib/schema.js:1646
let name;
if (utils.isPOJO(type) || type === 'mixed') {
return new MongooseTypes.Mixed(path, obj, null, this);
}
if (Array.isArray(type) || type === Array || type === 'array' || type === MongooseTypes.Array) {
// if it was specified through { type } look for `cast`
let cast = (type === Array || type === 'array')
? obj.cast || obj.of
: type[0];
// new Schema({ path: [new Schema({ ... })] })
if (cast?.instanceOfSchema) {
if (!(cast instanceof Schema)) {
if (this.options._isMerging) {
cast = new Schema(cast);
} else {
throw new TypeError('Schema for array path `' + path +
'` is from a different copy of the Mongoose module. ' +
'Please make sure you\'re using the same version ' +
'of Mongoose everywhere with `npm list mongoose`. If you are still ' +
'getting this error, please add `new Schema()` around the path: ' +
`${path}: new Schema(...)`);
}
}
return new MongooseTypes.DocumentArray(path, cast, obj, null, this);
}
if (cast &&
cast[options.typeKey] &&
cast[options.typeKey].instanceOfSchema) {
if (!(cast[options.typeKey] instanceof Schema)) {
if (this.options._isMerging) {
cast[options.typeKey] = new Schema(cast[options.typeKey]);
} else {
throw new TypeError('Schema for array path `' + path +
'` is from a different copy of the Mongoose module. ' +View on GitHub (pinned to 49cdab0136)
When it happens
Trigger: Thrown at lib/schema.js:1646 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Automattic/mongoose@49cdab0136 (2026-08-21).
Data as JSON: /api/errors/9ee176e8c60ff356.
Report an issue: GitHub.