search

Home  >  Q&A  >  body text

node.js中require的问题

举个例子:在一个项目的主程序server.js中引入mongoose模块,又在另一个文件use.js中给mongoose定义格式和自定义方法,最后在sever.js引入这个文件,可在use.js为什么又要引入mongoose模块,主程序server.js中不是以及经引入了么?
求大佬告知

PHPzPHPz2786 days ago464

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 16:13:26

    The use module is only referenced by the server, but mongoose is required in use. It is not defined and still needs to be introduced.
    http://www.infoq.com/cn/articles/nodejs-module-mechanism

    reply
    0
  • Cancelreply