error TS1192: Module has no default export [Solved]

In this reactjs tutorial, we will discuss how to fix an error, error TS1192: Module has no default export. The solution will fix the below type of error:

  • error TS1192: Module has no default export
  • error TS1192 module has no default export
  • error ts1192 module ‘ http ‘ has no default export
  • error ts1192 module moment has no default export
  • error ts1192 module node_modules/moment/moment ‘ has no default export
  • error TS1192: Module ‘A.module’ has no default export
  • error TS1192: Module ‘ “D:/SPFx/CRUDReact1/node_modules/@types/react/index” ‘ has no default export.

error TS1192: Module has no default export

The error comes while developing a SharePoint framework crud operations using react application. When I run the below command:

gulp build

It displays an error like below:

error TS1192: Module has no default export
error TS1192: Module has no default export

When I checked the code in the .tsx file, I saw the code like below:

import React, { Component } from 'react';
error ts1192 module moment has no default export
error ts1192 module moment has no default export

This line was creating the issue.

Then I have modified the code like below:

import * as React from 'react';

export default class CRUDReact extends React.Component<IHelloWorldProps, IStates> {

The other way, you can also modify the code like below:

import { React, Component } from 'react';

If you will write the above code, the error will not appear.

You may like the following tutorials:

I hope this tutorial helps you to learn how to fix error, error TS1192: Module has no default export.

>