skip to Main Content

I’m trying to use node to use the photoshop api, I am currently trying to make a code based on the example of text edit, but, I can’t deal with the fs.readFileSync, I need to use this to to configurate my private key, for that, I need to put the path to my key, but It says “module bot found”

fs.readFileSync("C:UsersjpcamOneDriveÁrea de TrabalhopsdTesteprivate.key"),

I don’t know what I can do to this work

Can anyone help me?

I ve tried using also only the file name of the key, because the Kay and the code are in the same folder

2

Answers


  1. make sure that the key file and your script file are in the same folder and try this

    fs.readFileSync(path.join(__dirname,"private.key"))
    
    Login or Signup to reply.
  2. In Javascript, the backslash is used as the escape character. For example, n makes a newline character.

    If you do console.log("C:UsersjpcamOneDriveÁrea de TrabalhopsdTesteprivate.key") you’ll notice that the result is C:UsersjpcamOneDriveÁrea de TrabalhopsdTesteprivate.key.

    Escape the escape character to get a backslash:

    fs.readFileSync("C:\Users\jpcam\OneDrive\Área de Trabalho\psdTeste\private.key");
    

    Alternatively, you can use String.raw() with a tagged template string:

    fs.readFileSync(String.raw`C:UsersjpcamOneDriveÁrea de TrabalhopsdTesteprivate.key`);
    

    Template literal strings use backticks, not single quotes.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search