Noob needs help installing code mirror

Hi,

I am a web/node noob and have attempted to install code mirror using:

npm i codemirror

as per google suggestions and https://www.npmjs.com/package/codemirror as I can’t find any installation instructions at the codemirror site.

But now what, how is my web app meant to ‘find’ the various libs? Example code on the codemirror site says I should use:

import {EditorView, basicSetup} from “codemirror”
import {javascript} from “@codemirror/lang-javascript”

But since npm installs stuff to a node_modules dir, the browser can’t find these dependencies.

What am I missing? Does the web page need to be served from a node js server of some kind? I know you can serve vue/react etc pages via node and it does all sorts of magic stuff, but my webapp will not be served by a node server so it needs to be able to run standalone.

I can ‘cheat’ by copying/pasting codemirror.js from the node_modules or the codemirror site, but I’d like to do all this the ‘right’ way. Or is just copying/pasting stuff from node_modules the ‘right’ way in this case!

Sorry for the stupid questions. I really don’t do enough web stuff, and each time I return to do a bit it seems to have become 1000 times more complex than last time!

Also, I can’t seem to find a lang-javascript.js file anywhere.

Bye,
Mark

OK, just read ‘bundling with rollup’ which suggests I do in fact have to serve my app with node js during development, and use something called ‘rollup’ to create releases, is this about right? A bit of a shame we have to build webapps these days, but that’s ‘progress’ for ya I guess!

I don’t think this is true. You can serve with any standard web server.

My limited understanding is that ‘rollup’ looks at your imports, looks at dependencies, does tree shaking, and creates a ;‘minimal’ output js file with just what is needed to run the app.

Yeah, does seem a bit unnatural at first.