Skip to content

Package subpath './package.json' is not defined by "exports" in /Users/xxx/my_repo/node_modules/cesium/package.json #8992

Closed
@rapha-opensource

Description

@rapha-opensource

This is Cesium installed via npm and integrated in a Svelte/Sapper route.

  1. npm install cesium
  2. Add a Svelte page to a Sapper basic demo app for the route /cesium which will load a basic Cesium Viewer.
  3. run npm run dev

The Svelte page

<script>
    import { onMount } from 'svelte'
    import "cesium/Build/Cesium/Widgets/widgets.css" // <= the first cesium import will cause the error !

    onMount(async () => {
        window.CESIUM_BASE_URL = 'http://localhost:3000/'
        const { Viewer } = await import('cesium')
        var viewer = new Viewer('cesiumContainer')
    })
</script>

<style>
    #cesiumContainer {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        overflow: hidden;
    }
</style>

<svelte:head>
    <title>Cesium Demo</title>
</svelte:head>
<div id="cesiumContainer"></div>

The error message

Package subpath './package.json' is not defined by "exports" in /Users/xxx/repos/my_repo/node_modules/cesium/package.json

Workaround

Delete the exports field in node_modules/cesium/package.json.
Re-launch npm run dev.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions