0

I am beginner in Node JS.I have questions... I want to export multiple modules is node with module.exports when i use requre my code work but don't work with import {} from.I know Node js doesen't provide ES6.But if i change my package.json and write type:module it can work.With export default my app work with import but with module.exports it can't work. I asked because in my last interview i got this question.And in my fitback there was this:Exporting multiple entities with <exports.[name-of-entity]>

Please help rosolve it))

import lib from "./index2.js"

lib.double()
function double(){
    return console.log('Hello double')
}

function trouble(){
    return console.log('Hello trouble!')
}

module.exports = {
    double,
    trouble
}

1 Answers1

1

Import and require are not the same.

This link is informative

The difference between "require(x)" and "import x"

Soroush Bgm
  • 482
  • 2
  • 15