N
N
noombasa2020-04-19 01:19:04
JavaScript
noombasa, 2020-04-19 01:19:04

Named import in node?

I want to do it , but an error occurs.import { Router } from 'express';

The requested module 'express' does not provide an export named 'Router'

Added a field to package.json . With this entry, named imports from files that end in ".js" work fine, but when you try to make from a package, the above error appears. How can this problem be solved? "type": "module",

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
y0u, 2020-04-19
@noombasa

The requested module 'express' does not provide an export named 'Router'

The error clearly states why.
import express from 'express'

const router = express.Router()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question