I know there are lots of "marked is not a function" questions, but they don't solve my problem, hence here is the question.
Previously I think I npm i marked and npm i react-markdown, then I try to include markdown using the solution How do I load a markdown file into a react component?
However, I keep getting either of these error:
The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received null
at new NodeError (internal/errors.js:322:7)
at Hash.update (internal/crypto/hash.js:84:11)
at Bundle.getHash (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Bundle.js:301:12)
at Bundle.package (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Bundle.js:186:23)
at Bundle.package (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Bundle.js:198:30)
at Bundle.package (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Bundle.js:198:30)
at Bundler.bundle (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Bundler.js:325:49)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Timeout._onTimeout (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Bundler.js:817:7)
Or
/home/azureuser/NCD_demo/main_project/src/webpages/assets/posts.md: marked is not a function
at MarkdownAsset.generate (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/assets/MarkdownAsset.js:12:12)
at async MarkdownAsset.process (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Asset.js:217:24)
at async Pipeline.processAsset (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Pipeline.js:46:7)
at async Pipeline.process (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Pipeline.js:24:23)
at async Object.run (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/worker.js:15:12)
at async Bundler.loadAsset (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Bundler.js:577:19)
at async /home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Bundler.js:610:13
at async Promise.all (index 4)
at async Bundler.loadAsset (/home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Bundler.js:599:21)
at async /home/azureuser/NCD_demo/main_project/node_modules/parcel-bundler/src/Bundler.js:610:13
I got the first error if I run npm run dev then I uncomment this line, after which it reloads itself
const content = require('./assets/posts.md');
Then I got the latter error if I don't comment it, CTRL+C the previous npm dev run, then npm dev run again with it uncommented.
I got the same error if I do this instead:
import file from "./assets/posts.md";
I even try to
Without the line, everything runs fine.
I even tried remove package-lock.json and node_modules, remove the dependencies for React-markdown and marked packages (so they don't get installed), but I still got the similar problem: Except that I don't get the first error but white screen of death.
Anyone encountered the same problem before could help me understand what is happening with this? Which error code is correct and how should I fix it?
Thanks in advance.