0
0 Comments

Error [ERR_MODULE_NOT_FOUND]: Cannot find module ‘C:\Users\minal\Desktop\ecommstore\backend\models\userModel.js’ imported from C:\Users\minal\Desktop\ecommstore\backend\routes\seedRoutes.js

I am getting this error

import mongoose from ‘mongoose’;

const userSchema = new mongoose.Schema(
{
name: { type: String, required: true },
email: { type: String, required: true, unique: true },
password: { type: String, required: true },
isAdmin: { type: Boolean, default: false, required: true },
},
{
timestamps: true,
}
);

const User = mongoose.model(‘User’, userSchema);
export default User;

import express from ‘express’;
import Product from ‘../models/productModel.js’;
import data from ‘../data.js’;
import User from ‘../models/userModel.js’;

const seedRouter = express.Router();

seedRouter.get(‘/’, async (req, res) => {
await Product.remove({});
const createdProducts = await Product.insertMany(data.products);
await User.remove({});
const createdUsers = await User.insertMany(data.users);
res.send({ createdProducts, createdUsers });
});
export default seedRouter;

Basir Answered question October 13, 2022