javascriptvitemapboxdeck.gl

Unable to detect MapboxLayer from deck.gl/mapbox


Following this.

I have following in my package.json:

{
  "name": "cesium-deckgl-viewer-vite",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build",
    "preview": "vite preview"
  },
  "devDependencies": {
    "typescript": "~5.6.2",
    "vite": "^6.0.1"
  },
  "dependencies": {
    "@deck.gl/core": "^9.0.38",
    "@deck.gl/geo-layers": "^9.0.38",
    "@deck.gl/mapbox": "^9.0.38",
    "@loaders.gl/3d-tiles": "^4.3.3",
    "@loaders.gl/core": "^4.3.3",
    "@probe.gl/log": "^4.0.9",
    "mapbox-gl": "^3.8.0"
  }
}

And in my index.js:

import {MapboxLayer} from '@deck.gl/mapbox';

But it gives me error:

Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/@deck__gl_mapbox.js?v=5cb1e8a3' does not provide an export named 'MapboxLayer'

What is missing in my setup?


Solution

  • Seems like you are using @deck.gl/mapbox v9. Check the documentation here, it say: MapboxLayer has been removed. Use MapboxOverlay instead.