Skip to content

Vite build fails with sass-embedded when running via tsx #735

@serkodev

Description

@serkodev

Acknowledgements

  • I read the documentation and searched existing issues to avoid duplicates
  • I understand this is a bug tracker and anything other than a proven bug will be closed
  • I understand this is a free project and relies on community contributions
  • I read and understood the Contribution guide

Minimal reproduction URL

https://github.com/serkodev/tsx-issue-735

Problem & expected behavior (under 200 words)

When running a Nuxt build using TSX

import { runMain } from '@nuxt/cli'
runMain()

The process fails with a sass-embedded error:

Nuxt Build Error: [vite:css] [sass] Cannot read properties of undefined (reading 'initAsyncCompiler')

From Reproduction Repo

Clone the repo and run:

pnpm i

# run with error
pnpm run build:tsx

The build works with no error when running the same .ts file via Bun or ts-node.

pnpm run build:bun
pnpm run build:ts-node

From Scratch

Show all steps
  1. Create an empty Nuxt project by npm create nuxt@latest.

  2. Install dependencies:

    pnpm i -D @nuxt/cli sass-embedded
  3. Add a SCSS style in app.vue:

    <style lang="scss">
    body {
      color: red;
    }
    </style>
  4. Create nuxt.ts with:

    import { runMain } from '@nuxt/cli'
    runMain()
  5. Run:

    tsx ./nuxt.ts build

    The error message will appear.

Bugs are expected to be fixed by those affected by it

  • I'm interested in working on this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions