Skip to content

Using Swiper causing error #11514

@PSMJonas

Description

@PSMJonas

Describe the bug

Unfortunately, Swiper 7 (as ESM package) and react-create-app do not seem to work together. When I install Swiper 7 as node-module and import it, I get the error message:

Module not found: Can't resolve 'swiper/react' in [...]

The docu says:

Swiper NPM package is now a pure ESM package. Which means it doesn't have CommonJS modules anymore (the ones with require() and module.exports syntax) and contains only native ES modules. If your bundler/tooling/environment doesn't support Node ES module, you should update it or stay on Swiper 6.

Unfortunately, a downgrade is not an option for me.

Did you try recovering your dependencies?

Yes.

Which terms did you search for in User Guide?

  • ESM package
  • ES Module

Environment

Environment Info:

current version of create-react-app: 4.0.3
running from C:\Users\jonas\AppData\Roaming\npm-cache_npx\3348\node_modules\create-react-app

System:
OS: Windows 10 10.0.19043
CPU: (12) x64 AMD Ryzen 5 2600 Six-Core Processor
Binaries:
Node: 14.17.1 - C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm: 6.14.13 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: Not Found
Edge: Spartan (44.19041.1023.0), Chromium (94.0.992.38)
Internet Explorer: 11.0.19041.1202
npmPackages:
react: ^17.0.2 => 17.0.2
react-dom: ^17.0.2 => 17.0.2
react-scripts: 4.0.3 => 4.0.3
npmGlobalPackages:
create-react-app: Not Found

Steps to reproduce

  1. create react app
  2. install Swiper
  3. import Swiper

Expected behavior

Swiper as an ESM package should be loaded.

Actual behavior

The module can't be found.

screen

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    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