Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
264 views
in Technique[技术] by (71.8m points)

node.js中require的问题

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

use模块只是被server引用了,但是use中需要mongoose,是没有定义的,还是需要引入。
http://www.infoq.com/cn/articles/nodejs-module-mechanism


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...