Figma API and "child_process"

I’m using VS Code and the Figma API to make a plug-in that does some language processing via a python file that imports NLTK.

I’ve tested the plug in’s functionality (with out NLP bit) and it works. I can retrieve/add info/elements from/to Figma’s canvas.
I’ve tested the python file via the terminal 'python3" and it also works.

I can also call the python’s function from the .ts file, but when I try use a something like
"import { spawn } from “child_process”;
I get this error
"Cannot find module 'child_process' or its corresponding type declarations"
I thought “child_process” part of the node js pgkg?
I tried to solve the issue by running and installing it 'npm install --save-dev @types/node'

This solves the problem, but creates a conflict with in the @figma/plugin-typings > index.d.ts with this error, which sense since being declared twice.

"Cannot redeclare block-scoped variable 'console'.ts(2451)

globals.d.ts(28, 13): 'console' was also declared here.

const global.console: Console"

While the code runs/works from terminal…the plug-in’s build no longer updates.
This my tsconfig.son file

  "compilerOptions": {
    "module": "commonjs",
    "target": "es2018",
    "lib": ["es2018"],
    "strict": true,
    "moduleResolution": "node",
    "typeRoots": [

I’ve also tried installing 'npm install --save-dev @types/node" inside a virtual environment with the plug in’s project to avoid conflict, but that didn’t help.

My question is how do I set up the Projects environment in VS Code to use Figma API and ‘child_process’ and avoid Conflicts. does Figma typings have a “child_process” equivalent.


1 Like

@Marcelo_Corvezola Were you able to find a fix for the issue?