TypeError: childProcess.spawn is not a function

Hello,

I am creating a package to open a link using the Open 8.4.2 library, which is already included in the Coda SDK. Also, I’m using Node v20.10.0 and NPM v10.2.3.

When I test it from the CLI, it generates the following error:

TypeError: childProcess.spawn is not a function

I have checked the index.js file in the Open library, and indeed, in line 224, it defines the following variable:

const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);

This spawn function is the one causing the error.

Does anyone know how to solve this problem?

Thank you very much for your help.

Hi @Damantia_Technologies - It appears that library is attempting to use a library that is only available in the Node.js runtime, which Coda Packs don’t have access to.

The execution environment provides access to the standard built-in JavaScript objects, but doesn’t support Web APIs or Node.js APIs.

What are you trying to use that library for? Packs don’t have access to the user’s local machine, so there is no way for them to open a URL or an executable.

Hi Eric, thank you for your support.

I’ve seen the documentation that you posted and now I understand how it works.

The purpose of this pack was to create a formula to open an URL like OpenWindow Coda function with new parameters like (open in the current tab, a new tab or new window).

I see, thanks for the clarification. Pack code runs in a tightly controlled sandbox, such that it can’t take direct actions like opening windows, etc. I like to think of a Pack as sort of like a pen pal: it can receive letters and reply back, but it only knows what you tell it and it can’t make changes directly.