-
-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Describe the bug
I tried to start my development environment but it failed with the following error.
[plugin:vite:import-analysis] Failed to resolve import "react" from "src/main.tsx". Does the file exist?
Reproduction
vite.new/react-ts
Steps to reproduce
Download the template from vite.new/react-ts
Run yarn set version canary to use the latest version of yarn with PnP
Change vite dependency in package.json
Run yarn to install all dependencies
Run yarn dev to start the development environment and the error will show up
System Info
System:
OS: macOS 26.1
CPU: (8) arm64 Apple M2
Memory: 81.50 MB / 16.00 GB
Shell: 3.2.57 - /bin/sh
Binaries:
Node: 24.11.0 - /usr/local/bin/node
Yarn: 4.12.0 - /usr/local/bin/yarn
npm: 11.6.1 - /usr/local/bin/npm
Browsers:
Safari: 26.1Used Package Manager
yarn
Logs
Plugin: vite:import-analysis
File: /Users/shaoyumeng/Downloads/vitejs-vite-rmp7t7yz/src/App.tsx:1:25
1 | import { useState } from "react";
| ^
2 | import reactLogo from "./assets/react.svg";
3 | import viteLogo from "/vite.svg";
2:03:25 PM [vite] (client) Pre-transform error: Failed to resolve import "react" from "src/App.tsx". Does the file exist?
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.