mercurylanded
V2EX  ›  Node.js

nodejs中能够判断这个模块是程序入口么。就像python里面 if __name__ == 'main' : 这样的。

  •  
  •   mercurylanded · Dec 19, 2012 · 4644 views
    This topic created in 5003 days ago, the information mentioned may be changed or developed.
    2 replies    1970-01-01 08:00:00 +08:00
    jackyz
        2
    jackyz  
       Dec 19, 2012
    if(!module.parent){
    console.log('我是程序入口');
    }
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1172 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 23:37 · PVG 07:37 · LAX 16:37 · JFK 19:37
    ♥ Do have faith in what you're doing.