var Queue = require('tinyqueue');
When trying to execute my script in Illustrator I get the following Illustrator error message:
Error 24: require is not a function. Line: 3 -> var Queue = require('tinyqueue');
I wonder if there is a problem with my package.json file? Is the ‘require’ (and f.e. ‘class’) keyword supported at all for Illustrator scripting? Do I need to add a #include line to my script to read the package.json file?
I would be grateful if someone could instruct me in solving this error!
Copy link to clipboard
Hi Silly-V, thank you for your reply! I succeeded to “port” the code A new algorithm for finding a visual center of a polygon | by Mapbox | maps for developers for usage in Illustrator (‘tinyqueue’ module isn’t really required for this code, a simple ‘new Array()’ does the job). I succeeded to use the algo to place the labels and result is better than using the ‘center of gravity’ method but is still not satisfying in case of 'nested' shapes. I’ll post another request to see if somebody can help. Thanks again!
The only method I have found for "importing" external code is to use an #include e.g.
what about importing into the new format? How do you do that?
New format as in UXP, which isn't available for Illustrator yet? You'd use modern methods like require or import but it's important to note that not everything is available in UXP and it's a custom engine, so not every 3rd party library will work out of the box like ones that rely on modules with custom UXP implementations like fs.