Turbo87 / sidebar-v2

A responsive sidebar with tabs for Leaflet, OpenLayers, Google Maps, ...
https://turbo87.github.io/sidebar-v2/examples/
MIT License
850 stars 336 forks source link

Failed to resolve 'ol/control/Control' from 'node_modules/sidebar-v2/js/ol5-sidebar.js` #322

Closed minorsecond closed 1 year ago

minorsecond commented 1 year ago

I'm trying to run npm run build build I get the error in the title, using OpenLayers 5.4.0.

I've gotten it to work before, so I know it's possible, I just can't remember what exactly needs to be done.

Here's the full error message:

@parcel/core: Failed to resolve 'ol/control/Control' from './node_modules/sidebar-v2/js/ol5-sidebar.js'

  C:\Users\rossw\WebstormProjects\PacketMap\node_modules\sidebar-v2\js\ol5-sidebar.js:2:21
    1 | // JS imports
  > 2 | import Control from 'ol/control/Control';
  >   |                     ^^^^^^^^^^^^^^^^^^^^
    3 |
    4 | export default class Sidebar extends Control {
minorsecond commented 1 year ago

Figured it out:

after running npm install:

  1. In node_modules/sidebar-v2/package.json, add an ol dependency line
  2. In node_modules/ol/control.json, add this: export {default as Sidebar} from 'sidebar-v2/js/ol5-sidebar.js';