首页
注册
登录
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请
登录
广告
V2EX
›
Node.js
nodejs中能够判断这个模块是程序入口么。就像python里面 if __name__ == 'main' : 这样的。
mercurylanded
·
2012 年 12 月 19 日
· 4235 次点击
这是一个创建于 4770 天前的主题,其中的信息可能已经有所发展或是发生改变。
__
Python
Nodejs
2 条回复
•
1970-01-01 08:00:00 +08:00
1
qiao
2012 年 12 月 19 日
1
http://stackoverflow.com/questions/8864365/can-i-know-in-node-js-if-my-script-is-being-run-directly-or-being-loaded-by-an/8864401#8864401
2
jackyz
2012 年 12 月 19 日
if(!module.parent){
console.log('我是程序入口');
}
关于
·
帮助文档
·
自助推广系统
·
博客
·
API
·
FAQ
·
Solana
·
2862 人在线
最高记录 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 26ms ·
UTC 13:50
·
PVG 21:50
·
LAX 05:50
·
JFK 08:50
♥ Do have faith in what you're doing.
❯