why node uses require not import?

后端 未结 3 1435
难免孤独
难免孤独 2021-02-19 20:08

I\'m learning node.js and am wondering why it uses the require syntax rather than the import syntax which React uses.

i.e.

const

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-19 20:47

    I believed import is es6 but I don't think that explains why it's not used in node.

    Just like the way NodeJS implements their entire library which tons of asynchronous functions which only support callback-based approach. Thinking this way and you'll realize that, sooner or later, the NodeJS framework will definitely support the import syntax and upgrade all of those asynchronous functions to support promise-based.

提交回复
热议问题