Skip to main content
Question

Figma API and "child_process"

  • July 26, 2023
  • 1 reply
  • 740 views

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 myNLTK.py" 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": [
      "./node_modules/@types",
      "./node_modules/@figma"
      
    ]
    
  }
}

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.

Thanks

This topic has been closed for replies.

1 reply

  • 3 replies
  • August 2, 2023

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings