Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't import the named export 'clearIntervalAsync' (reexported as 'clearIntervalAsync') from default-exporting module (only default export is available) #49

Closed
mike-lischke opened this issue Nov 29, 2022 · 1 comment

Comments

@mike-lischke
Copy link

mike-lischke commented Nov 29, 2022

Hi, after upgrading all my dependencies in my React (CRA) app, including set-interval-async I now get the error:

Can't import the named export 'clearIntervalAsync' (reexported as 'clearIntervalAsync') from default-exporting module (only default export is available)

when building it. I checked the type definitions to see where that mentioned default export is, but couldn't find any. There are only named exports, so I'm a bit clueless now how to solve this import issue.

I'm using the latest version of set-interval-async (3.0.2), Node.js version 18.12.1 and this is my import line:

import { clearIntervalAsync, setIntervalAsync, SetIntervalAsyncTimer } from "set-interval-async/dynamic";
@ealmansi
Copy link
Owner

ealmansi commented Jan 1, 2023

unfortunately, it looks like create react app (CRA) does not handle ECMAScript modules (mjs files) correctly.

if you search for "create react app mjs" you will find many possible solutions, including this one which works here for this library.

you just need to make sure that the test includes both cjs and mjs files:

webpackConfig.module.rules.push({
  test: /\.(c|m)js$/,
  include: /node_modules/,
  type: "javascript/auto"
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants