Reference error on node.js while include file

后端 未结 2 1345
离开以前
离开以前 2021-01-19 19:13

I\'m new to node.js. i have two files. they are index.js and db.js

my index.js is

var connection =          


        
2条回答
  •  说谎
    说谎 (楼主)
    2021-01-19 20:08

    node.js treats every file as a module. so to include any source file into another you need to export it at the source end and import it using require at the importing file.

提交回复
热议问题