R
R
rd1002021-10-05 20:47:53
Node.js
rd100, 2021-10-05 20:47:53

How to combine the ability to use import and require?

When trying to use import, it gave an error that it is possible only in modules
Added a property to Jason
"type": "module"
Since then, it began to swear at require
How to combine them?

const express = require('express')
const app = express()
const port = 3300
import {currency} from './api/currency.js'

app.get('/', (req, res) => {
  res.send('Hello World!')
})

app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`)
})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2021-10-05
@rd100

https://www.npmjs.com/package/commonjs-variables-f...
made for myself, use it to your health

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question