V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
mercurylanded
V2EX  ›  Node.js

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

  •  
  •   mercurylanded · Dec 19, 2012 · 4401 views
    This topic created in 4889 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   ·   2789 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 01:40 · PVG 09:40 · LAX 18:40 · JFK 21:40
    ♥ Do have faith in what you're doing.