How to reference NPM-installed three.js from another NPM-installed library and/or another JS script?

Trying to set up an example of THREE with this MeshLine implementation. Running on VSCode with Live Server extension, port 5500, Firefox. Already tried several combinations of import, require, with or without the type=”module” attribute, every time there is a different error. I have the feeling this is because I installed this as NPM modules instead of linking the scripts directly (I did this to be able to use the @types definitions for three), but I just cannot manage to fully understand the JS module ecosystem and variations.

Question
Is it possible to use these libraries (actually three.meshline which requires three) via NPM (= without directly linking the scripts) and if yes, how? Alternatively how to reference NPM three from non-NPM three.meshline script?

/// index.html

<script src="node_modules/three/build/three.module.js"
    type="module"></script>
<!-- <script src="node_modules/three.meshline/src/THREE.MeshLine.js"
    type="module"></script> -->
<script type="module">
    import("./node_modules/three.meshline/src/THREE.MeshLine.js")
</script>


/// THREE.MeshLine.js

;(function() {
  'use strict'

  var root = this
  var has_require = typeof require !== 'undefined'

  console.log(root.THREE)  // undefined
  console.log(has_require) // false

  var THREE = root.THREE || (has_require && require('three')) // <-- Uncaught TypeError: root is undefined
  if (!THREE) throw new Error('MeshLine requires three.js')   // <-- never managed to pass this test

  // (implementation code here)...

  if (typeof exports !== 'undefined') {
    if (typeof module !== 'undefined' && module.exports) {
      exports = module.exports = {
        MeshLine: MeshLine,
        MeshLineMaterial: MeshLineMaterial,
        MeshLineRaycast: MeshLineRaycast,
      }
    }
    exports.MeshLine = MeshLine
    exports.MeshLineMaterial = MeshLineMaterial
    exports.MeshLineRaycast = MeshLineRaycast
  } else {
    root.MeshLine = MeshLine
    root.MeshLineMaterial = MeshLineMaterial
    root.MeshLineRaycast = MeshLineRaycast
  }
}.call(this))