Cannot find name 'figma' error on setting up Figma plugin

2.5k Views Asked by At

I'm new to TS and JS.

Now I'm trying to set up my first plugin using the guide on macOS.

At some point I got an error:

/code.ts:9:1 - error TS2304: Cannot find name 'figma'.

I followed all the steps from the guide

I suppose the next action in the Terminal.app should have solved the problem, but it did not

sudo npm install --save-dev @figma/plugin-typings
Password:
npm WARN saveError ENOENT: no such file or directory, open '/Users/username/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/Users/username/package.json'
npm WARN username No description
npm WARN username No repository field.
npm WARN username No README data
npm WARN username No license field.

+ @figma/[email protected]
updated 1 package and audited 1 package in 2.72s
found 0 vulnerabilities

The first line of "*.ts" code(except comments) looks like:

figma.showUI(__html__);

I write C++, Swift, Objective-C, some Java a lot and there are some include/import statements. But here is none. I don't know how to deal with it in TS at the moment. =(

PS Thanks for your time

1

There are 1 best solutions below

0
On BEST ANSWER

Just run this command in a project directory.

Use:

cd <path to your project directory>

to change directory. TIP: Print "cd ", simply drag and drop the project directory into the "Terminal.app" to not to print the full path manually.

Than:

npm install --save-dev @figma/plugin-typings

I did it in another directory. There is no info about it in the guide.