Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid path error #12

Closed
connertennery opened this issue Oct 30, 2020 · 7 comments · May be fixed by #13
Closed

Invalid path error #12

connertennery opened this issue Oct 30, 2020 · 7 comments · May be fixed by #13

Comments

@connertennery
Copy link
Owner

Sorry to pester you again :)
I am getting the following error.

PS C:\Users\ DummyMe\Desktop\New folder> node main
Notion Export Path:
A
readline.js:1147
            throw err;
            ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
    at Object.readdirSync (fs.js:950:10)
    at fixNotionExport (C:\Users\ DummyMe\Desktop\New folder\main.js:200:28)
    at C:\Users\ DummyMe\Desktop\New folder\main.js:239:17
    at Array.forEach (<anonymous>)
    at fixNotionExport (C:\Users\ DummyMe\Desktop\New folder\main.js:238:14)
    at C:\Users\ DummyMe\Desktop\New folder\main.js:11:17
    at Interface._onLine (readline.js:327:5)
    at Interface._line (readline.js:658:8)
    at Interface._ttyWrite (readline.js:1003:14)
    at ReadStream.onkeypress (readline.js:205:10) {
  code: 'ERR_INVALID_ARG_TYPE'
}

PS. I ran the old main.js it worked fine (not the table linking, but ran)
image

Originally posted by @dummifiedme in #11 (comment)

@connertennery
Copy link
Owner Author

The issue comes from csvDirectory being undefined on line 200 before it's passed into correctCSVLinks. This occurs because the CSV is referencing links that are not in a subdirectory and instead exist somewhere else within the whole export.

e.g. A/B/C/database.csv references A/X/Y/file.md

connertennery referenced this issue Oct 30, 2020
Looks for a matching file for the first cell on each line of a CSV then creates a link
@dummifiedme
Copy link

Oh. But how can that be? I mean, any entry in a database is essentially a page.

@connertennery
Copy link
Owner Author

@dummifiedme Every entry is a page, but that entry can reference a page anywhere else in your Notion workspace. The change for #10 only looked in the subdirectory. I just need to change it so it can reference things anywhere.

@dummifiedme
Copy link

Are you sure about this?
I thought every entry creates a page inside this database specifically.
Even if you try to mention or [[]] a page, it is essentially a hyperlink in the title of the new pade thus created in the database.

Oh maybe!
It is unable to read the hyperlinks in the title!!

@connertennery
Copy link
Owner Author

@dummifiedme Yeah, I saw that it was null so it wasn't able to read the directory, hence the path is invalid error. I've made some changes to deal with that and handling there being nothing passed into the correctCSVLinks function.

This runs on three different Notion exports without errors, so I hope it works okay, but I think there may be some slight errors. There are known issues in this. For example, there's the possibility of there being a comma within a field, which messes up the parsing. However, fields with commas are exported with double quotes around them so it shouldn't be too difficult to deal with in the future. I just don't have the time right now. I'm going to make a pull request for the code as is though, so if you want, you can try that out.

@dummifiedme
Copy link

Please have a look at it.
https://github.com/visualcurrent/Notion-2-Obsidan

It doesn't create a table from databases but creates links to the pages. It's not as refined as your output, but databases part, you can take some inspiration? if you have some time :)

@connertennery
Copy link
Owner Author

@dummifiedme Sorry for the delay in this. I was hoping to cover it in an overhaul of the script but that never really became an option. Is this still an issue for you or can I close it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants