I've just created a React project with Vite. My project displays correctly in the browser, but when I press CTRL+C in the terminal to quit, I encounter this error: "ELIFECYCLE Command failed with exit code 1." It seems to be related to pnpm, because when I use npm run dev and then press CTRL+C, I don't get the error! I'm quite puzzled by this situation, and I'm struggling to resolve the problem this time. Despite having pnpm installed and the correct version, I can't seem to fix it. Could you please help me? Thank you very much.
$ pnpm install
Packages: +244
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are hard linked from the content-addressable store to the virtual store.
Content-addressable store is at: C:\Users\MarionPro\AppData\Local\pnpm\store\v3
Virtual store is at: node_modules/.pnpm
Progress: resolved 266, reused 244, downloaded 0, added 244, done
dependencies:
- react 18.2.0
- react-dom 18.2.0
devDependencies:
- @types/react 18.2.15 (18.2.20 is available)
- @types/react-dom 18.2.7
- @vitejs/plugin-react 4.0.3 (4.0.4 is available)
- eslint 8.45.0 (8.47.0 is available)
- eslint-plugin-react 7.32.2 (7.33.1 is available)
- eslint-plugin-react-hooks 4.6.0
- eslint-plugin-react-refresh 0.4.3
- vite 4.4.5 (4.4.9 is available)
Done in 14.8s
$ ls index.html node_modules/ package.json pnpm-lock.yaml public/ README.md src/ vite.config.js
$ pnpm dev
[email protected] dev C:\Users\MarionPro\OneDrive\Documents\PORTFOLIO\my-portfolio vite
VITE v4.4.5 ready in 1360 ms
➜ Local: http://localhost:5173/ ➜ Network: use --host to expose ➜ press h to show help ELIFECYCLE Command failed with exit code 1.
Package.json :
{
"name": "my-portfolio",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.3",
"eslint": "^8.45.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"vite": "^4.4.5"
}
}
vite.js :
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
});
vite.config.mjsnpm create vite@latest my-react-app -- --template react, vite.config.js is created. I believe.jsworks fine when package.json contains"type": "module".