why node uses require not import?

后端 未结 3 1346
难免孤独
难免孤独 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:42

    Probably for historical reasons. node.js and chrome (v8 engine) are older than ES6 standard.

    On the other hand, see: How can I use an es6 import in node?

    You may use import, too.

提交回复
热议问题