Import / Require LayerKind for Photoshop UXP

i created my first UXP JavaScript plugin using UXP Developer Tool.

im having an issue where i dont know how to properly import modules… for example i want to import LayerKind but i cannot successfully do it using the below

const app = window.require("photoshop").app;
const LayerKind = window.require("photoshop");

 app.documents.forEach(document => {
        document.layers.forEach(layer => {
            if (layer.kind === {
                console.log(`layer name: ${}, layer kind: ${layer.kind}`);

if i use the like i am up in my code, it doesnt work. when i remove everything works fine.
also when i try to import using

import {LayerKind} from 'photoshop';

i get the below error:

index.js:1 Uncaught SyntaxError: Cannot use import statement outside a module
at e.exports.execScript (uxp://uxp-internal/domjs_scripts.js:2)
at l (uxp://uxp-internal/domjs_scripts.js:2)
at uxp://uxp-internal/domjs_scripts.js:2
at o._executeCallbacks (uxp://uxp-internal/domjs_scripts.js:2)
at o._executeIfReady (uxp://uxp-internal/domjs_scripts.js:2)
at Array. (uxp://uxp-internal/domjs_scripts.js:2)
at o._executeCallbacks (uxp://uxp-internal/domjs_scripts.js:2)
at o.done (uxp://uxp-internal/domjs_scripts.js:2)
at Object.s [as loadHtmlContent] (uxp://uxp-internal/domjs_scripts.js:2)
at Object._loadHtmlContent (uxp://uxp-internal/p…anager_scripts.js:1)

any idea on how i can fix all this?

Isn’t your LayerKind a photoshop object? And I think it’s available only in beta, or was this already released?

I don’t know the answer to any of your questions.

I don’t know where the LayerKind obj is. I think its an enum but I’m not really good at finding out all these things. That’s why I’m here asking for help

Looks like LayerKind isn’t available at all yet. Even in beta

Just double-checked the actual constants object, LayerKind is missing indeed.
Not sure if they forgot to add it, but layer.kind already changed from a number to a string:


So at least it’s a bit more readable now than comparing against a numeric value. I’m sure the LayerKind constant will follow soon.

oh wow i see, im surprised its missing. I guess Photoshop UXP is still in a very early stage?
either way, on my end, when i use:

document.layers.forEach(layer => console.log(layer.kind);

it returns a number. What i did for now was just turn that enum from up above to an object

const LayerKind = {
    "any" : 0,
    "pixel" : 1,
    "adjustment" : 2,
    "text" : 3,
    "vector" : 4,
    "smartObject" : 5,
    "video" : 6,
    "group" : 7,
    "threeD" : 8,
    "gradient" : 9,
    "pattern" : 10,
    "solidColor" : 11,
    "background" : 12,
    "groupEnd" : 13

It works fine, so if i do

layer.kind === LayerKind.text

it works just fine. Still, very strange that i have to create this object… i would assume it was already in UXP. I just hope i dont run into more things that are “not complete”. I have some legacy scripts that are crashing photoshop. need to upgrade. But either way, it works for now. im glad at least i got to the bottom of it. hopefully it will be added soon. Thank you guys for all your help

1 Like