Know what OS we are working On?

Can we able to get Os Name XD is currently running

Edit :slight_smile:

async function checkPlatform() {
    const storage = await require("uxp").storage;
    const pluginFolder = await storage.localFileSystem.getPluginFolder();
    var path = pluginFolder.nativePath;

var result = "";
if (path.startsWith("/Users")) {
    result = "mac"
} else if (path.startsWith("C:\\Users")) {
    result = "windows";
} else {
    result = "this_is_madness";
return result;


to get platform =>

            result => {
1 Like

Could we compare the plugin folder’s native path?

this is also i was thinking about @PaoloBiagini

do you using mac what pattern mac outputs


so if we call pluginfloder from api in mac it output as above
where did you find this

found that in plugin location docs

post updated see the code above if not to know what platform XD is Running

@PaoloBiagini test the code on mac if it is working ot not

Hi @PramUkesh,

it works fine!!!
Just one detail: on Mac the starting tilde means '/Users/username’
So, update the following:
if (pluginFolderPath.startsWith("/Users"))
and that’s it.

Thank you again.

There’s an easier way to get the current platform:

const platform = require("os").platform();
// will be "darwin" or "win10"

Thank you very much @kerrishotts!

Hi, it doesn’t work for me on Win 10 (version 1803) and on MacOs (version 10.14 18A391)

with this code

const platform = require("os").platform();

I obtain this in the console:


instead of:

// will be "darwin" or "win10"
1 Like

Are you using webpack or another bundler? If so, make sure “os” is an external dependency (otherwise you might not be seeing our module).

@kerrishotts is os module in api is an npm module or a custom built by adobe because i want to use process module in npm with present api(different form package.json model) its bit hard to implement

The os module in XD is custom, and currently only provides information on the current platform and the OS release.

Yes, the problem was webpack, thanks for the tips!

1 Like

Is os a module or a global class? If a module, is it a top-level module or is it something in the uxp “namespace”?

The documentation claims that it is a “global class” rather than a module. This may be confusing several people (example).

Perhaps a documentation fix is in order?

Sorry for the delay here – yes, the documentation is strange here. It’s a quirk of the docs generation process. We’re working on improving this over time.

The os module is behind require('os'), just like you’d do on Node.

1 Like