DEV Community

SeongKuk Han
SeongKuk Han

Posted on

21

[plugin:vite:import-analysis] Failed to resolve import "react/jsx-dev-runtime" from "src/index.tsx". Does the file exist?

A problem while migrating from CRA to Vite


Error Message:

[plugin:vite:import-analysis] Failed to resolve import "react/jsx-dev-runtime" from "src/index.tsx". Does the file exist?
Enter fullscreen mode Exit fullscreen mode

Solution: Add an option classic to jsxRuntime of the plugin react in the vite config file.

[vite.config.ts]

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import viteTsconfigPaths from 'vite-tsconfig-paths';
import svgrPlugin from 'vite-plugin-svgr';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react({
    jsxRuntime: 'classic' // Add this line
  }), viteTsconfigPaths(), svgrPlugin()],
});
Enter fullscreen mode Exit fullscreen mode

@vitejs/plugin-react : By default, the plugin uses the automatic JSX runtime. However, if you encounter any issues, you may opt out using the jsxRuntime option.

Image of Docusign

Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (7)

Collapse
 
bhatvikrant profile image
Vikrant Bhat

This removed that error but now I'm getting the react import not found error

Collapse
 
lico profile image
SeongKuk Han

If you can share the code or how to reproduce, I will look into that.

Collapse
 
ch264 profile image
Christina Hastenrath

Thank you, this saved me

Collapse
 
lico profile image
SeongKuk Han

Glad to hear that 👍

Collapse
 
fuvavi profile image
Fuvavi

Thanks so much. It's work very well.

Collapse
 
lico profile image
SeongKuk Han

glad it worked for you :)

Collapse
 
doankimhuyit profile image
Doan Kim Huy

Thank you so much!!!

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more