[JS] Is it possible to execute command line tool or executable? How?

Hello all,

I need a little help from the community, we’re currently try to create an app to run an executable from the command line, with childProcess.exec() written in Javascript eg. ‘ls -lA’.

Is that even possible? Or is it restricted based on the V8 engine of the Cloudflare workers?

const childProcess = require('child_process');


const executeCommand = async (command) => {
	return new Promise((resolve, reject)=> {
		childProcess.exec(command, (error, stdout, stderr) => {
			if (error) {
				console.log(`error: ${error.message}`);
				return reject(error);
			if (stderr) {
				console.log(`stderr: ${stderr}`);
				return reject(stderr);
			console.log(`stdout: ${stdout}`);
			return resolve(stdout)

This is the code snipped I’m trying to run, but when I run wrangler dev index.js --local it throws following error:

TypeError: childProcess.exec is not a function

Would be great if someone could help, thank you!

Best regards