mercurylanded
V2EX  ›  Node.js

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

  •  
  •   mercurylanded · Dec 19, 2012 · 4712 views
    This topic created in 5034 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   ·   2148 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 00:36 · PVG 08:36 · LAX 17:36 · JFK 20:36
    ♥ Do have faith in what you're doing.