Skip to content

Cannot find module sonner/dist/styles.css?url after upgrading to v2.0.4 #648

@janhesters

Description

@janhesters

Description
After upgrading Sonner from v2.0.3 to v2.0.4, the build fails with the following error:

Cannot find module 'sonner/dist/styles.css?url'

Prior to this release, importing styles worked correctly. It appears that the path or packaging of the CSS file was changed in v2.0.4.

It seems likely that the new release either removed or relocated dist/styles.css, but the documentation (and/or code) still expects to import it from sonner/dist/styles.css?url.

To Reproduce

  1. In your project, update package.json to use:

    "dependencies": {
      "sonner": "2.0.4",
      /* ...other dependencies... */
    }
  2. Run your package manager to install the new version:

    npm install
    # or
    yarn install
  3. In your application code, import the styles exactly as before. For example:

    import { Toaster } from "sonner";
    import "sonner/dist/styles.css?url";

or

import sonnerStyles from 'sonner/dist/styles.css?url';
  1. Start the dev server or build your application:

    npm run dev
    # or
    yarn dev
    # or however you build
  2. Observe the error in the console/terminal:

    Cannot find module 'sonner/dist/styles.css?url'
    

Expected Behavior

  • The CSS file should still be available at the same path (sonner/dist/styles.css) so that importing it using the ?url suffix works as before.
  • After upgrading, no import-related errors should occur, and the toast component should continue rendering with the correct default styling.

Actual Behavior

  • The import of sonner/dist/styles.css?url fails because the file is not found in the published dist/ directory of the 2.0.4 package.
  • As a result, the application build crashes, preventing usage of the Sonner Toaster and any related styling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions