-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mongoose 6.4.0: Cannot find name 'BufferConstructor' #11963
Comments
This comment was marked as resolved.
This comment was marked as resolved.
Same issue here! |
import { Schema, model, connect } from 'mongoose';
// 1. Create an interface representing a document in MongoDB.
interface IUser {
name: string;
email: string;
avatar?: string;
}
// 2. Create a Schema corresponding to the document interface.
const userSchema = new Schema<IUser>({
name: { type: String, required: true },
email: { type: String, required: true },
avatar: String
});
// 3. Create a Model.
const User = model<IUser>('User', userSchema);
run().catch(err => console.log(err));
async function run() {
// 4. Connect to MongoDB
await connect('mongodb://localhost:27017/test');
const user = new User({
name: 'Bill',
email: 'bill@initech.com',
avatar: 'https://i.imgur.com/dM7Thhn.png'
});
await user.save();
console.log(user.email); // 'bill@initech.com'
} |
Closing this - cause is out of date node types Fix: (You should really replace |
(@IslandRhythms FYI this does make [mongoose with typescript] incompatible with node versions below 16.6) |
@TomMettam no it doesn't, Mongoose is compatible with Node versions below 16.6. This is a bug in |
Prerequisites
Mongoose version
6.4.0
Node.js version
18.3.0
MongoDB server version
N/A
Description
After upgrading to mongoose 6.4.0, Typescript projects fail to build due to missing BufferConstructor in typings
Steps to Reproduce
Expected Behavior
No error
The text was updated successfully, but these errors were encountered: