Skip to content

bug: Directory import ... is not supported resolving ES modules imported from ... Did you mean to import "@ionic/core/components/index.js"? #30686

Closed as not planned

Description

@jschill

Prerequisites

Ionic Framework Version

v8.x

Current Behavior

Using @ionic/react together with react-router generates errors:

[vite] Internal server error: Directory import '/workspace/my-spa-app/node_modules/@ionic/core/components' is not supported resolving ES modules imported from /workspace/my-spa-app/node_modules/@ionic/react/dist/index.js
Did you mean to import "@ionic/core/components/index.js"?

Expected Behavior

No error :-)

Steps to Reproduce

  1. npx create-react-router@latest my-spa-app
  2. cd my-spa-app
  3. npm i @ionic/react
  4. cd app and edit root.tsx, add import { IonApp, setupIonicReact } from "@ionic/react"; invoke the setupIonicReact and wrap your template with IonApp
  5. Now go back to project root and npm run dev.

Code Reproduction URL

https://github.com/jschill/react-router-ionic-issue

Ionic Info

Not using the cli in this project, i just want the ui components. But this is my ionic info:

Ionic:

   Ionic CLI : 5.4.16

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   NodeJS : v22.14.0
   npm    : 11.2.0
   OS     : macOS Unknown


  ────────────────────────────────────────────────────────────

           Ionic CLI update available: 5.4.16 → 7.2.0

     The package name has changed from ionic to @ionic/cli!

             To update, run: npm uninstall -g ionic
                 Then run: npm i -g @ionic/cli

  ────────────────────────────────────────────────────────────

Additional Information

Node 22.x

Activity

  1. changed the title [-]bug:[/-] [+]bug: Directory import ... is not supported resolving ES modules imported from ... Did you mean to import "@ionic/core/components/index.js"?[/+] on Sep 19, 2025
  2. thetaPC commented on Sep 26, 2025

    @thetaPC
    Contributor

    Thank you for submitting the issue!

    When adding to an existing app, then @ionic/react-router should be used instead of react-router. We have a great guide on how to add Ionic to a React app that I recommend checking out.

  3. jschill commented on Oct 6, 2025

    @jschill
    Author

    If anyone else gets here who doesn't want to go down the @ionic/react-router-route because of the dependency on the quite old react router 5: I solved it by adding ssr.noExternal to my vite config. So my vite.config.ts ended up like this:

    import { reactRouter } from "@react-router/dev/vite";
    import tailwindcss from "@tailwindcss/vite";
    import { defineConfig } from "vite";
    import tsconfigPaths from "vite-tsconfig-paths";
    
    export default defineConfig({
      root: './src',
      build: {
        outDir: '../dist',
        minify: false,
        emptyOutDir: true,
        cssCodeSplit: false
      },
      plugins: [tailwindcss(), reactRouter(), tsconfigPaths()],
      ssr: {
        noExternal: ["@ionic/react", "@ionic/core"],
      }
    });
  4. ionitron-bot commented on Nov 5, 2025

    @ionitron-bot

    Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

  5. locked and limited conversation to collaborators on Nov 5, 2025
  6. added a commit that references this issue on Jun 1, 2026
    312a3a7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions