vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.09k stars 6.13k forks source link

create-vite: vanilla-ts template appears to be broken #18400

Closed amelekhin closed 4 days ago

amelekhin commented 4 days ago

Describe the bug

npm create-vite@latest with the vanilla-ts template produces a broken build. I have got the same results with Node versions 20 and 22 and with npm and pnpm package managers. I assume that there is a bug with reading or parsing JSON files. Please see the full reproduction in the attached repo.

Reproduction

https://github.com/amelekhin/vite-vanilla-ts

Steps to reproduce

  1. Initialize a new project with npm create-vite@latest. Choose any name, vanilla template, and TypeScript as a language. Follow the instructions of the setup utility.
  2. Run npm run dev.

System Info

System:
    OS: macOS 15.0.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 651.20 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.10.0 - ~/.nvm/versions/node/v22.10.0/bin/node
    npm: 9.7.2 - /opt/homebrew/bin/npm
    pnpm: 9.12.2 - ~/.nvm/versions/node/v22.10.0/bin/pnpm
  Browsers:
    Brave Browser: 130.1.71.114
    Safari: 18.0.1
  npmPackages:
    vite: ^5.4.8 => 5.4.9 

Used Package Manager

npm

Logs

Click to expand! ```shell ~/Development/Projects via Node v22.10.0 ❯ npm create vite@latest ✔ Project name: … vite-vanilla-ts ✔ Select a framework: › Vanilla ✔ Select a variant: › TypeScript Scaffolding project in /Users/anton/Development/Projects/vite-vanilla-ts... Done. Now run: cd vite-vanilla-ts npm install npm run dev ~/Development/Projects via Node v22.10.0 took 8s ❯ cd vite-vanilla-ts Development/Projects/vite-vanilla-ts via Node v22.10.0 ❯ npm install added 12 packages, and audited 13 packages in 2s 3 packages are looking for funding run `npm fund` for details found 0 vulnerabilities Development/Projects/vite-vanilla-ts via  v22.10.0 took 2s ❯ npm run dev > vite-vanilla-ts@0.0.0 dev > vite VITE v5.4.9 ready in 360 ms ➜ Local: http://localhost:5173/ ➜ Network: use --host to expose ➜ press h + enter to show help undefined:1 [Failed to load PostCSS config: Failed to load PostCSS config (searchPath: /Users/anton/Development/Projects/vite-vanilla-ts): [SyntaxError] Unexpected end of JSON input SyntaxError: Unexpected end of JSON input at JSON.parse () at jsonLoader (file:///Users/anton/Development/Projects/vite-vanilla-ts/node_modules/vite/dist/node/chunks/dep-Cyk9bIUq.js:25733:41) at Object.search (file:///Users/anton/Development/Projects/vite-vanilla-ts/node_modules/vite/dist/node/chunks/dep-Cyk9bIUq.js:25894:25)] Node.js v22.10.0 ```

Validations

amelekhin commented 4 days ago

Wow, apparently it is related to the fact that I accidentally created a package.json outside the project directory. The file was empty, but somehow it affects the project, even though there is a package.json within the project directory. So it's not vanilla-ts to blame.

I will close this issue, however perhaps it's still something worth looking into.