我遇到保存文件后(进行更改后)不自动重新渲染页面的问题。 Fsr,它在Powershell中工作,这很奇怪。如果需要的话,这是我的
package.json
文件:
{
"name": "vite-project",
"private": true,
"version": "0.0.0",
"type": "module",
"main": "dist/index.js",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"test": "tsc && jest"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@babel/preset-typescript": "^7.24.1",
"@types/jest": "^29.5.12",
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.19",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"jest": "^29.7.0",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.1",
"ts-jest": "^29.1.2",
"typescript": "^5.2.2",
"vite": "^5.2.0"
}
}
和
vite.config.js
文件:
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
注意:在 Ubuntu 中,它会在我点击
r+enter
后呈现,这会重置服务器。
所以我尝试了几种方法: • 更新Ubuntu • 删除
node_modules
和 package-lock.json
并重新安装所有依赖项
• 使用不同的节点版本(16.3.0、18.12.0、2012.2),顺便说一句,在 Powershell 中它适用于 18.12.0 版本
• 以及不同的npm 版本
• 在 https://vitejs.dev/guide/troubleshooting
部分中 Dev Server: Requests are stalled forever
我尝试增加文件描述符限制并增加以下 inotify 相关限制
• 删除整个项目并再次重新克隆我的项目
我想知道为什么它停止工作。之前效果非常好... 非常感谢您的帮助:)
在谷歌上搜索后,我发现了一个很棒的视频,它很有效!这是救星
https://www.youtube.com/watch?v=BUClW9wTqGQ&ab_channel=coder4life