skip to Main Content

I have a CRUD project based on react and nodejs. when I try to index.js, I recieve the following error: Named export ‘express’ not found ( please open the image to see the error)

The index.js code is the following

import express  from "express" ;
import cors from "cors" ;
import UserRoute from "./routes/UserRoute.js" ;
//import Types from 'mongoose'
const app =express(); 
app.use(cors()); 
app.use(express.json());
app.use(UserRoute); 
app.listen(5000,()=>console.log('server up and running...')) ;

The UserRoute.js file code is the following :

import { express } from "express";
import { getUsers }from "../controllers/UserController.js"
const router =express.router(); 
router.get('/users',getUsers); 
export default router

I hope you may help me to find the solution.

2

Answers


  1. import express from "express";
    
    Login or Signup to reply.
  2. can you please use it?

    const express = require("express");

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search