Node.Js - Get windows username

后端 未结 6 1597
臣服心动
臣服心动 2021-02-05 09:50

I am trying to get the windows username of the machine that is running my node.jS app (the app is always running on a Windows machine).

How can I get the current windows

6条回答
  •  忘掉有多难
    2021-02-05 09:54

    Someone has created a module called username that does all of the hard work for you.

    You use it like

    var username = require('username');
    
    console.log( username.sync() );
    

提交回复
热议问题