How do I use an NPM package in a vanilla HTML/CSS/JS project?

Viewed 1757

I have a simple website built with HTML, CSS, and some in-line JS. I want to be able to use this NPM package Simple MDE Markdown Editor, but I don't know how. I tried running npm install simplemde --save in my project directory. That created a node_modules folder with the NPM package inside it, but how do I import that into my project? If I just try to use the package without importing it in any way, I get an error:

Uncaught ReferenceError: SimpleMDE is not defined.

1 Answers

Using node_modules requires tools like Webpack. If your project is fully vanilla, you can try to add the cdn (I guess you need the links below), should work as npm module.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
Related