Skip to content

Module not found : React/JSX-runtime #136

@DaanDeMot

Description

@DaanDeMot

Describe the bug

Currently working with a React project 17 and after adding the React-Timezone-Select package I've got a build error saying the following :

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\Users\Daan\Desktop\Watcherr\hcp-dashboard\node_modules\react\jsx-runtime' imported from C:\Users\Daan\Desktop\Watcherr\hcp-dashboard\node_modules\react-timezone-select\dist\index.js
Did you mean to import "react/jsx-runtime.js"?

(I've added the jsx-runtime package aswell) The same error is happening aswell whenever I refresh the page where the React-timezone-selector is being used, only after a refresh, I can use the page without breaking it if I don't refresh the page.

Searched online for a long time but nothing seems to work.

Component I made using the TimezoneSelect :

export interface SelectTimeZoneProps {
  timezone: ITimezone,
  setTimezone: (value: ITimezone) => void,
  label: string,
  required?: boolean,
}

const TimezoneSelector: React.FC<SelectTimeZoneProps> = ({
  timezone,
  setTimezone,
  label,
  required,
}) => {
  return (
    <div>
      {label && <label className={styles.InputLabel}>{label + (required ? "*" : "")}</label>}
      <TimezoneSelect value={timezone} onChange={setTimezone}/>
    </div>
  );
};
export default TimezoneSelector;

and how I use it :

 <div className="row">
        <div className="col-12 col-md-6">
          <TimezoneSelector 
            timezone={selectedTimezone} 
            setTimezone={handleTimeZoneChange} 
            label={t('site-configuration.timezone')}
            required={false}/>
           
        </div>
        <div className="col-12 col-md-6">
          <Alert type={'message'}>
            {t('site-configuration.timezone.explanation')}
          </Alert>
        </div>
      </div>

And If I click on second link of the error msg it brings me to the index of the node_module package of React-timezone-select to this line :

import { jsx } from "react/jsx-runtime";
Has anyone got an idea on how I could fix this?

Many thanks in advance.

Reproduction

install and use react-timezone-select

System Info

Windows OS

Used Package Manager

yarn

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

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