Nbrower node : Saveas doesn't work?

Hi i use this flow to save a web page into a pdf file :

[
    {
        "id": "129d963431e3975c",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "a1c3b5dc9d7fc22e",
        "type": "nbrowser",
        "z": "129d963431e3975c",
        "name": "test",
        "methods": [
            {
                "name": "gotoURL",
                "func": "goto",
                "params": [
                    {
                        "type": "msg",
                        "value": "payload",
                        "typeDefault": "str"
                    }
                ]
            },
            {
                "name": "saveAs",
                "func": "saveAs",
                "params": [
                    {
                        "type": "saveAction",
                        "value": "pdf",
                        "typeDefault": "saveAction"
                    },
                    {
                        "type": "str",
                        "value": "/data/pdf/test.pdf",
                        "typeDefault": "str"
                    }
                ]
            }
        ],
        "prop": "nbrowser",
        "propout": "payload",
        "object": "msg",
        "objectout": "msg",
        "close": false,
        "show": true,
        "ssl": true,
        "outputs": 1,
        "x": 410,
        "y": 100,
        "wires": [
            []
        ]
    },
    {
        "id": "27100f4dbdee757d",
        "type": "inject",
        "z": "129d963431e3975c",
        "name": "https://flows.nodered.org/",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "https://flows.nodered.org/",
        "payloadType": "str",
        "x": 170,
        "y": 100,
        "wires": [
            [
                "a1c3b5dc9d7fc22e"
            ]
        ]
    }
]

But the file is not created. I forgot something ?
An idea ?

Hi, in order to make code more readable and importable it is important to surround your code with three backticks

```
 like this
```

You can edit and correct your post by clicking the pencil icon.

See this post for more details - How to share code or flow json

Done thx !

Well since your flow is only 2 nodes an inject and an nBrowser node - you are not doing anything with the result so you wont save anything.

I'm surprised because i thought that nbrowser was supposed to do the job :

My debug node show me nothing and the debug window remains empty after the injection.

My apologies, I have not used that node - I wrongly assumed it would output something from the output pin - for you to save.

Does it work if you select other save as type?

Does the path /data/pdf/ exist & can you access it (is this a docker node-red? and if so, do you know how to access /data/pdf/ to check if the file is written?)

Are there any errors in node-red terminal / log?

Yes the path exist, i have all rights (RW) and i can access to this folder, node red (the docker) too. I have no error message. It's strange.

I found an error in the.npm/logs folder :
27 Jan 15:33:41 - [red] Uncaught Exception:
27 Jan 15:33:41 - [error] Error: spawn /data/node_modules/electron/dist/electron ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:274:19)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-red-docker@2.1.6 start: node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-red-docker@2.1.6 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /data/.npm/_logs/2022-01-27T15_33_41_042Z-debug.log

node-red-docker@2.1.6 start /usr/src/node-red
node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"

But i don't understand the problem.

how have you installed node-red?

Is node-red installed in docker or directly?

What hardware and OS is this running on?

Are you running an electron version of node-red?

Hi,
It's a docker with a data folder with all rights (RW)
I use Portainer in my Qnap NAS to install the docker but I access to node red with a mac
I guess I don't run an electron version (how can i know that ? )
Thx

I only asked as i seen this...


Do you have a standard installation of node-red (like on your MAC or a raspberry pi) that you can try this - to rule out the usual docker issues?

I think i'm going to try to find another node to do the job. I don't know if it exists.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.