A module cannot have multiple default exports

18,894

Solution 1

Quick Way

As sometimes you can just reopen a file as stated in other answers, it doesn't always help, however.

Update: Dec 10, 2020. The previous option (see below) is not available in new versions of WebStorm. To restart the TS service now, you can use the following option:

New option

See more details on TypeScript tool window help center page.


Previous functionality (prior versions)

When you see lags like this one (and other weirdness from TS service), you can restart the TypeScript service by opening a TypeScript tool window and clicking on the "Restart" button (3rd button on the right side of the panel):

enter image description here

Solution 2

I had the same error. After restarting WebStorm it worked again.

Solution 3

Quickest way: Close and reopen the file!

Share:
18,894

Related videos on Youtube

MARCKON LIU
Author by

MARCKON LIU

Updated on December 11, 2020

Comments

  • MARCKON LIU
    MARCKON LIU over 3 years

    I have only one export default line in my code. However, in WebStorm with Typescript, I get this TS Error:

    Ts2528: a module cannot have multiple default exports

    Here is the code:

    ts import { ModelCreator } from 'entities/model-creator' export default ModelCreator()
    
    • Serhii Matrunchyk
      Serhii Matrunchyk over 3 years
      wanna make some answer accepted?
  • Nic Scozzaro
    Nic Scozzaro over 4 years
    Same issue in PyCharm
  • Athul Muralidharan
    Athul Muralidharan about 4 years
    Same issue in IntelliJ Idea
  • PANKAJ NAROLA
    PANKAJ NAROLA about 4 years
    for me, it worked just after reopening the file. so for ex: close the file which shows this error and reopen it. so, in this case, u can save the time of restarting a webstorm.. I hope it helps to someone.
  • MyStackRunnethOver
    MyStackRunnethOver over 3 years
    This solved my Intellij "A module cannot have multiple default exports" error as well
  • Taki
    Taki over 3 years
    Definitely better than restarting IDE. However still reproducible on PhpStorm 2020.2.3
  • David Gilbertson
    David Gilbertson over 3 years
    Pity they merged TypeScript into the Problems pane in 2020.3, I can't see how to restart TypeScript now.
  • Harry
    Harry over 2 years
    Thank you! This tip still paying dividends in 2021 with a react component issue I had with a default export
  • Serhii Matrunchyk
    Serhii Matrunchyk over 2 years
    Upd: Seems like this update resolved the issue finally youtrack.jetbrains.com/issue/WEB-47248