mercurylanded
V2EX  ›  Node.js

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

  •  
  •   mercurylanded · Dec 19, 2012 · 4452 views
    This topic created in 4910 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   ·   Solana   ·   1307 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 17:21 · PVG 01:21 · LAX 10:21 · JFK 13:21
    ♥ Do have faith in what you're doing.