Skip to content

@tailwindcss/vite Svelte: Cannot convert undefined or null to object #18003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
antipoly opened this issue May 14, 2025 · 4 comments
Closed

@tailwindcss/vite Svelte: Cannot convert undefined or null to object #18003

antipoly opened this issue May 14, 2025 · 4 comments

Comments

@antipoly
Copy link

What version of Tailwind CSS are you using?
v4.0.0

What build tool (or framework if it abstracts the build tool) are you using?
Vite 6.2.6

What version of Node.js are you using?
v22.15.0

What operating system are you using?
Windows


I created a new svelte project using npx sv create, selected tailwind as the only option.
The error in the title comes up when I run the server.

After tracing the minified code, the error seems to be from:
/packages/@tailwindcss-vite/src/index.ts:275

this.scanner = Scanner({ sources })

Scanner is an import from @tailwind/oxide
Don't know where to go from here, thanks

@wongjn
Copy link
Collaborator

wongjn commented May 14, 2025

Consider running the command npm ls tailwindcss. If the packages are of different versions, consider consolidating the @tailwindcss packages such that they all the same version. Otherwise, consider providing a git repo that reproduces the unexpected behavior.

@philipp-spiess
Copy link
Member

@antipoly You'll have to send us a reproduction to investigate, if I run npx sv create, it works fine:

α dev/throwaway npx sv create
Need to install the following packages:
[email protected]
Ok to proceed? (y) 

┌  Welcome to the Svelte CLI! (v0.8.3)
│
◇  Where would you like your project to be created?
│  testdbgsvl
│
◇  Which template would you like?
│  SvelteKit minimal
│
◇  Add type checking with TypeScript?
│  Yes, using TypeScript syntax
│
◆  Project created
│
◇  What would you like to add to your project? (use arrow keys / space bar)
│  tailwindcss
│
◇  Which plugins would you like to add?
│  none
│
◆  Successfully setup add-ons
│
◇  Which package manager do you want to install dependencies with?
│  pnpm
│
◆  Successfully installed dependencies
│
◇  Project next steps ─────────────────────────────────────────────────────╮
│                                                                          │
│  1: cd testdbgsvl                                                        │
│  2: git init && git add -A && git commit -m "Initial commit" (optional)  │
│  3: pnpm run dev --open                                                  │
│                                                                          │
│  To close the dev server, hit Ctrl-C                                     │
│                                                                          │
│  Stuck? Visit us at https://svelte.dev/chat                              │
│                                                                          │
├──────────────────────────────────────────────────────────────────────────╯
│
└  You're all set!

α dev/throwaway cd testdbgsvl/
α throwaway/testdbgsvl pnpm run dev --open

> [email protected] dev /Users/philipp/dev/throwaway/testdbgsvl
> vite dev --open

1:48:26 PM [vite] (client) Forced re-optimization of dependencies

  VITE v6.3.5  ready in 805 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help
^C%                                                  

@antipoly
Copy link
Author

Consider running the command npm ls tailwindcss. If the packages are of different versions, consider consolidating the @tailwindcss packages such that they all the same version. Otherwise, consider providing a git repo that reproduces the unexpected behavior.

Thank you.
There were indeed different versions of tailwind installed from different dependencies.

For anyone else: one of 2 things probably solved it:

  • Failed to execute the build script for @tailwindcss/oxide and svelte-preprocess. I'm not sure if I had ignored the warning before.

  • Installing the latest version of @tailwindcss/vite and tailwindcss and running pnpm dedupe

@philipp-spiess
Copy link
Member

Glad you could figure it out! Going to close the issue then if it's resolved. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants