开发者问题收集

Vite – “源图指向丢失的源文件”

2021-11-03
18972

突然间,几乎所有已安装的模块都出现此错误。

“C:/.../node_modules/.vite/react.js”的源映射指向缺少源文件 “C:/.../node_modules/.vite/axios.js”的源映射指向缺少源文件 “C:/.../node_modules/.vite/react-dom.js”的源映射指向缺少源文件 “C:/.../node_modules/.vite//react_jsx-dev-runtime.js”的源映射指向缺少源文件

package.json:

{
  "name": "ic-logistic",
  "version": "0.0.0",
    "proxy": "http://localhost:8080/",
  "private": true,
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "serve": "vite preview"
  },
  "dependencies": {
    "axios": "^0.24.0",
    "dotenv": "^10.0.0",
    "mapbox-gl": "^2.5.0",
    "react": "^17.0.0",
    "react-dom": "^17.0.0",
    "react-map-gl": "^6.1.17",
    "react-redux": "^7.2.5",
    "react-router-dom": "^5.3.0",
    "redux": "^4.1.1",
    "redux-devtools-extension": "^2.13.9",
    "sass": "^1.42.1"
  },
  "devDependencies": {
    "@vitejs/plugin-react": "^1.0.0",
    "vite": "^2.6.0"
  }
}
2个回答

只需将 @vitejs/plugin-react 版本从 "^1.0.0" 更改为确切版本 "1.0.5" 。您可以在此线程中阅读有关此错误的更多信息: https://github.com/vitejs/vite/issues/5438

Nefaris
2021-11-04

扩展@nefaris 的回答,对我来说,解决这个问题的方法是将 v1.0.x 替换为 1.0.8 :

npm install @vitejs/[email protected] --save-dev
Vladyslav Didenko
2022-08-09