Hey.
I’m currently developing a Markdown Previewer app using React-Redux and within the Create-React-App in Visual Studio Code environment. I tried to add Marked.js through both CLI: npm install -g marked
and In-browser: npm install marked --save
but the marked() method still remains undefined and thus it fails to compile.
Have you imported it inside of the file you are trying to use it in?
1 Like
Yes, I would install it locally with npm install marked --save
(or yarn add marked
). Then (as Lucas points out) you need to import
it into any file where you are going to use it, usually something like import marked from 'marked';
and then in that file you can use marked
as a function in that file.
2 Likes
Forgot to mention I tried to import it into the intended .js file. But, thank you for pointing that out, I realized I wrote the wrong module’s name. ‘Marked.min’, pretty silly mistake eh.
You can always check exactly what the module name is in you package.json file, under “dependencies”.