tsparticles / tsparticles

tsParticles - Easily create highly customizable JavaScript particles effects, confetti explosions and fireworks animations and use them as animated backgrounds for your website. Ready to use components available for React.js, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Inferno, Solid, Riot and Web Components.
https://particles.js.org
MIT License
7.57k stars 833 forks source link

[Bug]: Failed to resolve entry for package "tsparticles" #3911

Closed netcore-jroger closed 2 years ago

netcore-jroger commented 2 years ago

Contact Details

sjr_vip@126.com

What happened?

Describe the bug

After I use comand yarn add tsparticles tsparticles-engine react-tsparticles add these packages, I run yarn run dev command. than I got some exceptions.

✘ [ERROR] [plugin vite:dep-scan] Failed to resolve entry for package "tsparticles". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "tsparticles". The package may have incorrect main/module/exports specified in its package.json.

    node_modules/vite/dist/node/chunks/dep-27bc1ab8.js:38429:10:
      38429 │     throw new Error(`Failed to resolve entry for package "${id}". ` +
            ╵           ^

  This error came from the "onResolve" callback registered here:

    node_modules/vite/dist/node/chunks/dep-27bc1ab8.js:36968:18:
      36968 │             build.onResolve({
            ╵                   ~~~~~~~~~

other issue: https://github.com/vitejs/vite/issues/7754

Reproduction

https://stackblitz.com/edit/vitejs-vite-iyeunl?file=package.json&terminal=dev

System Info

System:
    OS: Windows 10 10.0.22000
    Memory: 9.65 GB / 31.89 GB
  Binaries:
    Node: 14.18.2 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.18 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.3.0 - ~\AppData\Roaming\npm\npm.CMD
  Browsers:
    Chrome: 100.0.4896.127
    Edge: Spartan (44.22000.120.0), Chromium (100.0.1185.39)
  npmPackages:
    @vitejs/plugin-react-refresh: ^1.3.6 => 1.3.6
    vite: ^2.9.5 => 2.9.5

Used Package Manager

yarn

Logs

✘ [ERROR] [plugin vite:dep-scan] Failed to resolve entry for package "tsparticles". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "tsparticles". The package may have incorrect main/module/exports specified in its package.json.

    node_modules/vite/dist/node/chunks/dep-27bc1ab8.js:38429:10:
      38429 │     throw new Error(`Failed to resolve entry for package "${id}". ` +
            ╵           ^

    at packageEntryFailure (E:\demo\node_modules\vite\dist\node\chunks\dep-27bc1ab8.js:38429:11)
    at resolvePackageEntry (E:\demo\node_modules\vite\dist\node\chunks\dep-27bc1ab8.js:38425:9)
    at tryNodeResolve (E:\demo\node_modules\vite\dist\node\chunks\dep-27bc1ab8.js:38232:20)
    at Context.resolveId (E:\demo\node_modules\vite\dist\node\chunks\dep-27bc1ab8.js:38040:28)
    at Object.resolveId (E:\demo\node_modules\vite\dist\node\chunks\dep-27bc1ab8.js:36609:55)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async resolve (E:\demo\node_modules\vite\dist\node\chunks\dep-27bc1ab8.js:36821:26)
    at async E:\demo\node_modules\vite\dist\node\chunks\dep-27bc1ab8.js:36978:34
    at async callback (E:\demo\node_modules\esbuild\lib\main.js:921:28)
    at async handleRequest (E:\demo\node_modules\esbuild\lib\main.js:701:30)

  This error came from the "onResolve" callback registered here:

    node_modules/vite/dist/node/chunks/dep-27bc1ab8.js:36968:18:
      36968 │             build.onResolve({
            ╵                   ~~~~~~~~~

    at setup (E:\demo\node_modules\vite\dist\node\chunks\dep-27bc1ab8.js:36968:19)
    at handlePlugins (E:\demo\node_modules\esbuild\lib\main.js:843:23)
    at Object.buildOrServe (E:\demo\node_modules\esbuild\lib\main.js:1137:7)
    at E:\demo\node_modules\esbuild\lib\main.js:2079:17
    at new Promise (<anonymous>)
    at Object.build (E:\demo\node_modules\esbuild\lib\main.js:2078:14)
    at Object.build (E:\demo\node_modules\esbuild\lib\main.js:1927:51)
    at E:\demo\node_modules\vite\dist\node\chunks\dep-27bc1ab8.js:36769:54
    at Array.map (<anonymous>)

  The plugin "vite:dep-scan" was triggered by this import

    src/layout/login/index.tsx:12:25:
      12 │ import { loadFull } from "tsparticles";
         ╵                          ~~~~~~~~~~~~~

Build failed with 1 error:
node_modules/vite/dist/node/chunks/dep-27bc1ab8.js:38429:10: ERROR: [plugin: vite:dep-scan] Failed to resolve entry for package "tsparticles". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "tsparticles". The package may have incorrect main/module/exports specified in its package.json.

Validations

Version

2.0.5

Which library are you using?

React.js (react-tsparticles, react-particles-js)

tsParticles Configuration

{
  "backgroundMode": {
    "enable": true
  },
  "fpsLimit": 60,
  "particles": {
    "number": {
      "value": 0
    },
    "collisions": {
      "enable": false
    },
    "color": {
      "value": "#ffffff"
    },
    "shape": {
      "type": "circle"
    },
    "opacity": {
      "value": {
        "min": 0.3,
        "max": 0.8
      }
    },
    "size": {
      "value": {
        "min": 1,
        "max": 10
      }
    },
    "move": {
      "enable": true,
      "size": true,
      "speed": 5,
      "direction": "none",
      "outModes": {
        "default": "destroy"
      },
      "trail": {
        "enable": true,
        "fillColor": "#000000",
        "length": 3
      }
    }
  },
  "detectRetina": true,
  "background": {
    "color": "#000"
  },
  "emitters": {
    "direction": "none",
    "rate": {
      "delay": 0.25,
      "quantity": 10
    },
    "position": {
      "x": 50,
      "y": 50
    },
    "size": {
      "width": 0,
      "height": 0
    },
    "spawnColor": {
      "value": "#ff0000",
      "animation": {
        "h": {
          "enable": true,
          "speed": 5
        },
        "l": {
          "enable": true,
          "speed": 0,
          "offset": {
            "min": 20,
            "max": 80
          }
        }
      }
    }
  }
}

What browsers are you seeing the problem on?

Firefox

Relevant log output

No response

Code of Conduct

matteobruni commented 2 years ago

Thanks @netcore-jroger, I've found the problem, there's a "module": "esm/index.js" that points to a non existing file, this will be fixed soon!

I need to check all build scripts (around 80 packages 😅) to see if there are similar cases