Can I call childProcess.exec()?

Hi all,

I am starting with UXP Plugins in Photoshop, and I need to import node modules.

But for example, when I try to import child_process for call external app, it says:

Module not found: “child_process”. Parent module folder was: “./”.

I am not sure if is it possible.

My code is:

const { exec } = require(“child_process”);

Is it already available?

Thanks!

UXP does not provide a full Node environment. Calling out to a child process is not currently possible. We are adding support for launching external apps, but this won’t be quite the same as a child process (no watching stdout, for example). Any interprocess comms would have to be negotiated between plugin and launched app.

We were facing the same issue with our plugins which relied heavily on a full Node environment. Our solution was to build a Node application that runs aside from the plugin.

To communicate with the Node application we use WebSockets but you could also use XMLHttpRequests. It’s a bit of a drag but we managed to rebuild all features that we used to have in the old environment.

Thanks for the reply @kerrishotts , but then I have more questions:

When will be available this? Is there more information about how it will work?

And thanks a lot for the solution @jjdenhertog, may be is a stupid question, but how do you launch this “backend” Node application that runs aside?

Currently it’s not possible to launch an application from UXP. So we add instructions to run an application besides the extension. We make a request to verify if the application is running, and display a message if it’s not the case.

As soon as there is an option to launch an external app we will probably simply show a button to launch the app.

1 Like