souvikinator / notion-to-md

Convert notion pages, block and list of blocks to markdown (supports nesting and custom parsing)
https://www.npmjs.com/package/notion-to-md
MIT License
1.08k stars 89 forks source link

fs.writeFile failing #70

Closed kerim closed 1 year ago

kerim commented 1 year ago

I am trying the code from the README. I added the API code and the page ID, saved it as notion-to-md.js and ran it using node. But I get the following error:

node notion-to-md.js
/Users/[user folder]/Downloads/notion-to-md.js:18
  fs.writeFile("test.md", mdString, (err) => {
  ^

ReferenceError: fs is not defined
    at /Users/[user folder]/Downloads/notion-to-md.js:18:3
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v19.9.0

I tried manually creating a file called test.md, but that didn't help - same error.

souvikinator commented 1 year ago

you have to import fs module like so:

const fs = require('fs');
kerim commented 1 year ago

It worked! Thanks