Possible BUG with Github OAuth2 & API tokens - wanting to import workflows back

Describe the issue/error/question

In trying to create an ‘import from github’ workflow (wish there was a ready made one available!) I might have discovered a bug, or might just be dumb.

When listing files in a Github directory, the token at the end of each download_url is different to the one that is accessable through the ‘RAW’ button within Githubs UI. As a result, you can’t access the raw data.

Over the hours of research, I read someone else having the issue with a different app and the developer ended up having to change something so not sure if this is a bug with n8n or a user error.

If anyone knows how to import previously backed up workflows from Github back into a self-hosted n8n, that would be very useful.

What is the error message (if any)?

404: Not Found

Please share the workflow

Share the output returned by the last node

404: Not Found

Information on your n8n setup

  • n8n version: latest
  • Database you’re using (default: SQLite): don’t know
  • Running n8n with the execution process [own(default), main]: don’t know
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: online

Hey @binvius,

Last time I had to do it I cloned my backup Git repo to my machine then ran the CLI tool to import all the workflows from the clone folder using n8n import:workflow --separate --input=n8n-backup/workflows/

I guess now what you could do is use the API to update the workflow and manage it all from workflows although it would probably take a bit of work to get it running.

Hey @binvius,
I tried out reading files from github using OAuth2 credentials. The response download_url field is exactly the same as the github RAW Button url. I tried the same with a private repo and it also worked :thinking:

Thanks Jon & Marcus - we have made some progress. It turns out those tokens are randomly generated and expire quite quickly. That’s why some appeared to be different and not found. If you use the tokens pulled from the workflow in a timely manner, there are no issues.

We now have the .json files saved locally but for some reason the final CLI execute command node is playing up. We have tried both on the directory with n8n import:workflow --separate --input=C:\path\to\local\dir\ and with single files using n8n import:workflow --input=filename.json

No matter what we try, we allways recieve something like:

ERROR: Command failed: n8n import:workflow --input=C:\Users\User\AppData\Local\Programs\n8n\import\snippets-store.json node:internal/modules/cjs/loader:937 throw err; ^ Error: Cannot find module 'C:\Users\User\AppData\Local\Programs\n8n\import:workflow' at Function.Module._resolveFilename (node:internal/modules/cjs/loader:934:15) at Module._load (node:internal/modules/cjs/loader:779:27) at Function.c._load (node:electron/js2c/asar_bundle:5:13331) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12) at node:internal/main/run_main_module:17:47 { code: 'MODULE_NOT_FOUND', requireStack: [] }
07/07/2022, 14:07:23
Data below may contain sensitive information. Proceed with caution when sharing.
NodeOperationError: Command failed: n8n import:workflow --input=C:\Users\User\AppData\Local\Programs\n8n\import\snippets-store.json
  throw err;

Error: Cannot find module 'C:\Users\User\AppData\Local\Programs\n8n\import:workflow'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:934:15)
    at Module._load (node:internal/modules/cjs/loader:779:27)
    at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
    at node:internal/main/run_main_module:17:47 {
  requireStack: []

    at Object.execute (C:\Users\User\AppData\Local\Programs\n8n\resources\app\node_modules\n8n-nodes-base\dist\nodes\ExecuteCommand\ExecuteCommand.node.js:74:27)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Workflow.runNode (C:\Users\User\AppData\Local\Programs\n8n\resources\app\node_modules\n8n-workflow\dist\src\Workflow.js:594:28)
    at async C:\Users\User\AppData\Local\Programs\n8n\resources\app\node_modules\n8n-core\dist\src\WorkflowExecute.js:537:49

Would anyone know how to workout where the error lies?

Thanks very much.

Not sure what changed but we started instead to recieve the error:

invalid (Cannot read properties of undefined (reading 'length'))]

Now we are consistantly recieving:

ERROR: Command failed: import:workflow --separate --input=C:\Users\User\AppData\Local\Programs\n8n\import\ The filename, directory name, or volume label syntax is incorrect.

We’ve tried chaining commands together to first get into that directory but after many hours of research and attempts, we are no closer.

We then discovered this help doc which states a different command that must point to the absolute path so we have tried:

"C:\VTRoot\HarddiskVolume3\Users\User\AppData\Local\Programs\n8n\resources\app\node_modules\n8n\bin\n8n.cmd" export:workflow --all


"C:\Users\User\AppData\Local\Programs\n8n\resources\app\node_modules\n8n\bin\n8n.cmd" export:workflow --all

Despite the sucess of another user, both of those commands produce the error:

ERROR: Command failed: "C:\Users\User\AppData\Local\Programs\n8n\resources\app\node_modules\n8n\bin\n8n.cmd" export:workflow --all 'node' is not recognized as an internal or external command, operable program or batch file.

There must be some way to be able to import/export from a local host (on Windows at the moment.)

Thanks if anyone has any tips.

Not sure if it’s connected but I opened up 5 of our bigger workflows this morning a few times each and each only contained two or three random nodes. (They were possibily really old unused workflows that were deleted long ago as I am almost sure I saw out of the corner of my eye, a workflow number that was way too high for all of the workflow numbers that are currently in production.) However, they are now opening up with the correct workflow data so not sure what was happening there. Anyway, thought I’d mention it in case it means anything.

We are still unable to import or export locally on Windows, which was installed using the main installer from the main site. We have tried hundreds of things, including the workflow provided by MutedJam in the link above which for us, throws the error: is not recognized as an internal or external command...

It’s a bit of a mystery but am hopeful that there must be someone on the planet that has been able to import/export locally on Windows.

Thanks all for anything at all.

Hi @binvius,
I tried replicating you problems on windows. The following worked for me.

  1. cmd/powershell inside .n8n folder - cd C:\Users\<USER>\.n8n
  2. Export Workflows - n8n export:workflow --all --output=workflows.json
  3. Export Credentials - n8n export:credentials --all --output=credentials.json

Your .n8n folder should look something like this

Import also worked

  1. Import Workflows - n8n import:workflow --input=workflows.json
  2. Import Credentials - n8n import:credentials --input=credentials.json

Can you try this out and check your versions for node, npm and n8n.


Hi @marcus,
Sorry for the delay (we didn’t receive any notification so will have to look into that.)

Thank you very much for looking into this for all similar potential Windows users.

To provide a bit of context… as there was no mention of anything otherwise, we had perhaps mistakenly assumed the Windows installer would instal everything it needed to fully run n8n. Because it opens and works, we likely mistakenly thought that there would be nothing else required. When we run n8n -v, node -v and npm -v, they all error as none of that was installed on this particular windows box.

We then discovered this troubleshooting page and followed its guide but as far as we can tell, almost every line errors or warns due to much of it being legacy, depreciated, etc. (perhaps that page could all do with updating at some point down the line.) We then installed all the requirements ourselves and added them to PATH but upon then installing with npm install n8n -g, it prints the following:

Are we right in assuming the windows installer is to be installed alongside an npm instal?

Does anyone know if anyone has kindly put together a very brief step-by-step of installing on Windows? (If it doesn’t already exist, we think this would be a great idea as many new users are likely to be on Windows and simply give up, which is then potentially substantial lost future revenue.)

Thank you very much if you/anyone has any ideas at all as it’s been a week since we first started with all this so we’d love to get things working if possible.

Hey @binvius,
did you install our n8n desktop app? Sorry, I was assuming you did a global npm install. I do not have experience using n8n commands like import/export from cmd using our desktop app. I am not even sure how that would work. Below I show my windows installation process that worked.


Install nodejs version 16 LTS. The installer gives you an option to automatically install the necessary tools. If you do that you shouldn’t need our troubleshooting page.

Please restart your windows machine after installation. You should now be able to do this.


Install n8n

Execute npm install n8n -g to install n8n as a global package. Ignore the deprecated warnings.

Start n8n

Execute n8n start to start n8n from command line. If you are getting an error, try executing n8n start from another folder, e. g. the .n8n folder inside your user folder. This is a problem sometimes happening on windows.

Hey @binvius,

In theory the desktop app should have everything you need, Looking at the earlier command you were on the right lines you need to use the full path using the cmd file in %localappdata%.

I can see you are using powershell as the terminal shell of choice which I think could be the default now but what happens if you first run cmd to swap over to the older shell then try the export command? It could be that you need to change the slashes from \ to /

1 Like

Hey @marcus

Firstly, thank you very very much for putting together the step-by-step guide - I think that’ll be very useful to many users.

Both really. We were initially trying with the windows installer as per this comment but have also been trying with an npm install alongside that windows installer incase it needed it to work properly.

Having started n8n via cmd/ps, everything works fine in the browser localhost:5678 - the issue lies in the windows installer throwing errors. Because almost every windows user (and therefore potentially substantial future revenue) will not be familiar with starting things via a windows flavoured cli like cmd or ps, this is why we were keen to get the export and import commands working in the Execute Command node of the windows installer version, whilst also allowing for alt-tabbing between windows.

Looking at the error from this previous comment, it would appear the windows installer version cannot find a module it needs under C:\Users\User\AppData\Local\Programs\n8n

I’m not too familiar with these things but as there is no ‘n8n’ file (without a filetype) in that directory, perhaps it needs to point to ‘n8n.exe’ like the other commands point to the respective cmd file.

I’m not sure if it’s just Jan or others that contribute towards the code and whether or not winning potential windows users are of any priority as I’m sure everyone has a very packed roadmap.

Thank you for sticking with us and for any other ideas you ‘might’ have at all.

Hey @Jon

Thank you very much for your comments.

Similar to my response to Marcus, we had been trying both the windows installer and when that didn’t work, we tried npm to compliment it.

We have tried the windows installer on a fresh install of windows and when using the Execute Command node to export or import, it produced the error from this previous comment so, maybe it’s not currently working fully out of the box.

We have tried so many different commands in the Execute Command node to export or import, could you possibly please provide the exact command you are suggesting.

(NB: there is an n8n.exe file in C:\Users\User\AppData\Local\Programs\n8n and an n8n.cmd file in C:\Users\User\AppData\Local\Programs\n8n\resources\app\node_modules\n8n\bin)

Thank you very much for ‘any sort of help’ you can provide at all - I would think many future windows users would also be equally thankful.

I would try running the .cmd file which I think is what the docs mention.

But before running it in your terminal swap over to cmd and see if that helps.

I might have a clean windows vm somewhere that I can use for testing when I am back from leave next week unless @MutedJam has any ideas.

Hey all, I just tested running C:\Users\Tom\AppData\Local\Programs\n8n\resources\app\node_modules\n8n\bin\n8n.cmd export:workflow --all through the Execute Command node on my end using the Desktop version of n8n on Windows and didn’t run into any trouble here:

I even re-installed the desktop app after removing all of its local data (that’s why it has only one workflow I’ve just created in the screenshot). This was my test workflow:

So I think the problem might not be with n8n desktop in general and we’d need more information to reproduce this exact problem.

1 Like

Hi @MutedJam

Thank you very much for your help. Hopefully, Jon enjoys his well-deserved break.

OK, so we are not receiving an error with the export command at the moment and have spent quite some time trying to reproduce different install flows so as to determine where the original error occurred from, so as to help out the community, which we will report back on this once we have something worth reporting.

Despite trying many many angles, we are still unable to import back in, so what would really help would be if you could provide the code that you use in the Execute Command node for importing back.

We have searched the machine and are not finding a workflow.json file anywhere to reference to so if you happened to know the flow that n8n uses to export and import on the windows desktop version, that would be very helpful too, for all windows users as well. Something like the following would be great:

To export in windows desktop, use the Execute Command node with: C:\Users\User\AppData\Local\Programs\n8n\resources\app\node_modules\n8n\bin\n8n.cmd export:workflow --all

This saves the backup file to: ???

To import that backup file, use the Execute Command node with: ???

Just those few pieces of information will help all future windows users so thank you very much if you are able to help with that.

Hey binvius,
I just tried using these commands with n8n desktop on windows. It worked for me.

Hey @marcus
Thank you very much for this.

It is not showing any errors when ran in CMD, the issue we’re facing is getting commands to work in the ‘Execute Command’ node within the UI of n8n, as mentioned in more detail in this previous post.

Whilst exporting via an Execute Comand node within the UI of n8n throws no errors, the importing via an Execute Comand node within the UI of n8n, errors with stuff shown above and:

NodeOperationError: Command failed: C:\Users\User\AppData\Local\Programs\n8n\resources\app\node_modules\n8n\bin import:workflow --input=workflow.json
'C:\Users\User\AppData\Local\Programs\n8n\resources\app\node_modules\n8n\bin' is not recognized as an internal or external command,
operable program or batch file.

    at Object.execute (C:\Users\User\AppData\Local\Programs\n8n\resources\app\node_modules\n8n-nodes-base\dist\nodes\ExecuteCommand\ExecuteCommand.node.js:74:27)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Workflow.runNode (C:\Users\User\AppData\Local\Programs\n8n\resources\app\node_modules\n8n-workflow\dist\src\Workflow.js:594:28)
    at async C:\Users\User\AppData\Local\Programs\n8n\resources\app\node_modules\n8n-core\dist\src\WorkflowExecute.js:537:49

Worth noting that whilst it doesn’t throw an error when exporting as also proven by @MutedJam in this previous post above, there is no actual workflows.json file created anywhere on the machine when exporting via the ‘Execute Command’ node within the UI of n8n (as there correctly is when exporting via CMD.)

We feel like there will be many many revenue-generating windows users who would rely on being able to export/import using the ‘Execute Command’ node within the UI of n8n, so very much thank you for any help to get this working for all of us windows users.