You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the bug has not already been reported
Mongoose version
8.0.3
Node.js version
10.2.3
MongoDB server version
10.2.3
Typescript version (if applicable)
No response
Description
the punycode deprecation warning is originating from within the mongoose package, specifically from a dependency used by mongoose named tr46. This is not uncommon with complex Node.js applications, where a dependency of a dependency might use deprecated features.
// index.js
import express from 'express';
import dotenv from 'dotenv';
import { MongoClient} from 'mongodb';
import productRoutes from './routes/productRoutes.js';
import userRoutes from './routes/userRoutes.js';
import cartRoutes from './routes/cartRoutes.js';
dotenv.config();
const app = express();
const PORT = process.env.PORT || 3000;
// MongoDB connection
const uri = process.env.MONGODB_URI;
const client = new MongoClient(uri);
async function connectToMongoDB() {
try {
await client.connect();
console.log("Connected to MongoDB");
} catch (error) {
console.error("Failed to connect to MongoDB", error);
}
}
connectToMongoDB();
// Middleware for parsing JSON and form data
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
It's also possible this is resolved by mongodb 6.3.0. Looks like that upgraded mongodb-connection-string-url which upgraded whatwg-url which upgraded tr4 to a version that should not have the deprecation warning anymore. Other than looking at the latest package.json files I didn't actually verify whether or not it really does fix it.
Prerequisites
Mongoose version
8.0.3
Node.js version
10.2.3
MongoDB server version
10.2.3
Typescript version (if applicable)
No response
Description
the punycode deprecation warning is originating from within the mongoose package, specifically from a dependency used by mongoose named tr46. This is not uncommon with complex Node.js applications, where a dependency of a dependency might use deprecated features.
Steps to Reproduce
node --trace-deprecation index.js
npm install mongoose@latest
npm update mongoose
"scripts": {
"start": "node --trace-deprecation index.js",
}
Expected Behavior
run my code without this message
// index.js
import express from 'express';
import dotenv from 'dotenv';
import { MongoClient} from 'mongodb';
import productRoutes from './routes/productRoutes.js';
import userRoutes from './routes/userRoutes.js';
import cartRoutes from './routes/cartRoutes.js';
dotenv.config();
const app = express();
const PORT = process.env.PORT || 3000;
// MongoDB connection
const uri = process.env.MONGODB_URI;
const client = new MongoClient(uri);
async function connectToMongoDB() {
try {
await client.connect();
console.log("Connected to MongoDB");
} catch (error) {
console.error("Failed to connect to MongoDB", error);
}
}
connectToMongoDB();
// Middleware for parsing JSON and form data
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
// Routes
app.use('/api/products', productRoutes);
app.use('/api/users', userRoutes);
app.use('/api/cart', cartRoutes);
app.listen(PORT, () => {
console.log(
Server is running on port ${PORT}
);});
The text was updated successfully, but these errors were encountered: