Hi everyone, just wanted to share this importer I made. You just need to export your Notion notes, unzip the file, and then run this script using Node.
There is a little documentation on the GitHub README but I was encouraged to share this point in particular: Warning: Notion pages that contain parentheses or dashes in the title will have them removed by Notion while exporting your data so the file will be created without them, even though the link itself will still retain them.
Thanks for creating this! Looks good!
Iām excited to try it.
I tested it on macOS Mojave with node 10.13
First try:
Ran node main and when it asked for Notion Export path I dragged the folder over the terminal window (works with most command line utils in macOS).
Got this error:
readline.js:1032
throw err;
^
Error: ENOENT: no such file or directory, scandir '/Users/rsdimitrov/Downloads/Export-b7bea5ff-da8c-48e2-864e-3ee93310425f '
Second try:
Fixed the above error by manually trimming the extra whitespace at the end of the path.
Then got this error
readline.js:1032
throw err;
^
Error: ENOENT: no such file or directory, rename '/Users/rsdimitrov/Downloads/Export-b7bea5ff-da8c-48e2-864e-3ee93310425f\.DS_Store' -> '.DS_Store'
at Object.renameSync (fs.js:591:3)
at fixNotionExport (/Users/rsdimitrov/Downloads/Notion-to-Obsidian-Converter-master/main.js:153:7)
at rl.question (/Users/rsdimitrov/Downloads/Notion-to-Obsidian-Converter-master/main.js:10:17)
at Interface._onLine (readline.js:288:5)
at Interface._line (readline.js:638:8)
at Interface._ttyWrite (readline.js:919:14)
at ReadStream.onkeypress (readline.js:168:10)
at ReadStream.emit (events.js:182:13)
at emitKeys (internal/readline.js:424:14)
at emitKeys.next (<anonymous>)
Third try:
Deleted .DS_Store folder from the root path
Then got this:
readline.js:1032
throw err;
^
Error: ENOENT: no such file or directory, rename '/Users/rsdimitrov/Downloads/Export-b7bea5ff-da8c-48e2-864e-3ee93310425f\Inbox aa646ee03f274e3c8053c8ae3f794295.md' -> '/Users/rsdimitrov/Downloads/Export-b7bea5ff-da8c-48e2-864e-3ee93310425f\Inbox.md'
at Object.renameSync (fs.js:591:3)
at fixNotionExport (/Users/rsdimitrov/Downloads/Notion-to-Obsidian-Converter-master/main.js:153:7)
at rl.question (/Users/rsdimitrov/Downloads/Notion-to-Obsidian-Converter-master/main.js:10:17)
at Interface._onLine (readline.js:288:5)
at Interface._line (readline.js:638:8)
at Interface._ttyWrite (readline.js:919:14)
at ReadStream.onkeypress (readline.js:168:10)
at ReadStream.emit (events.js:182:13)
at emitKeys (internal/readline.js:424:14)
at emitKeys.next (<anonymous>)
Judging by the errors your script assumes Iām not on an unix-based system and my filesystem uses backslashes \ instead of forwardslashes /
Suggestions
Make it accept command line parameters instead of asking for the path once the script is run. This way I can use the autocomplete function of the bash/terminal and construct the correct path easier.
Edit: Fixed it to run without errors on macOS by changing line 144 from var currentPath = path + '\\' + currentDirectory[i].name;
to var currentPath = path + '\/' + currentDirectory[i].name;
Hi, @rsdimitrov, thank you for finding that issue. I had to make a previous change because a user found it wasnāt working on Ubuntu. Iām sorry Iām just now seeing this; I donāt get on the forum frequently and I only get notifications for GitHub issues. Iāll make this an issue and get around to fixing it as soon as I get the free time.
Thank you for trying it out and letting me know the issues you came across!
Thanks. I got it to work under Linux. For others, if you want to run javascript from the terminal, your need to install nodejs first. Install command:
sudo apt install nodejs
Didnāt have luck getting the script to recognize the file path for my notion export in Linux (elementary OS). Could very well be my own error. Ran flawlessly in mac OS.
Hi, could someone please explain this more directly & simply?
I am a mac user trying to figure out how to do this, but my knowledge is lacking. I installed the nodejs, but am not sure how to run the script, nor how to do that with the node.
Iād appreciate any help I can get!!
Thanks for putting the effort into developing this tool. FYI I had this error when I tried to run it.
/main.js:27
let bn = npath.basename(name);
^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
Hi @froggy, I just did this on my MacBook Pro (Big Sur 11.4). Here are the steps I used (apologies if they are too pedantic, I am not sure what level of understanding you are at). Thereās a couple of things that could go wrong in this process, so feel free to reply with any errors.
Check to make sure you have Node.js installed by opening a Terminal and typing in node -v. It should come up with a version number rather than ācommand not foundā.
Get the script from OP (@rail)'s public GitHub repository onto your own machine. The file you need is main.js. You can do this in a couple of ways:
Clone the repository locally, onto your own machine. (If you have Git and know how to use it, this is probably the easiest option.)
Download the whole repository as a ZIP file and unzip it locally to get the files. You can see the option to download the ZIP under the bright āCodeā menu in the homepage of the GitHub repo (here).
Download the individual file by looking at the āRawā verison of it on GitHub. In other words, save this file.
If you havenāt already, export the Notion workspace (or individual page/databse) that you want to convert as āMarkdown + CSVā, and save it somewhere locally (unzipping as necessary). Take note of the path to the top-level directory of the unzipped export.
Open a Terminal window and navigate to the directory that contains the script (the one you cloned or saved the script to).
Once there, start the script execution using the command node main in Terminal.
The script will prompt you to enter the absolute directory of your exported Notion files (this is the top-level directory that I mentioned in step 3).
Once you enter that directory, and assuming everything went well, the script will execute the conversion, and tell you how many files were converted, how long it took, etc.
Thatās it! If you check the directory of your Notion exports you should see that the markdown filenames have changed, the links etc. inside are converted to an Obsidian-readable format, and you have a new markdown file with a markdown table for every CSV file in the original export.
Hope this helps
BTW @rail, thanks for this nice little tool. Really easy and simple, and saved me some time and trouble!
Thanks for your clear instructions,I am successful in importing my Notion notes and also huge thanks to @rail for this simple and time efficient tool !!