Skip to content

[Bug]: inertia init unable to find import alias #1817

@noxasch

Description

@noxasch

Reproduction

https://github.com/noxasch/shadcn-rails-inertia-repro

Describe the bug

I'm using vite inertia rails project and doesn't follow the inertia php path for the tsconfig.json.

pnpm dlx shadcn-vue@latest init
✔ Preflight checks.
✔ Verifying framework. Found Inertia.
✔ Validating Tailwind CSS config. Found v4.
✖ Validating import alias.
                                                                                                                                                                                    
No import alias found in your tsconfig.json file.                                                                                                                                   
Visit https://shadcn-vue.com/docs/installation/manual to learn how to set an import alias.   

I looked into shadcn-vue repo and found that it is hardcoded and make an assumption the location to the tsconfig.json

// get-project-info.ts - line 76-79
if (packageInfo?.dependencies?.['@inertiajs/vue3']
    || packageInfo?.devDependencies?.['@inertiajs/vue3'] || (await fs.pathExists(path.join(cwd, 'resources/js')))) {
    return FRAMEWORKS.inertia
  }

...
// line 223
export async function getTsConfigAliasPrefix(cwd: string) {
  const detectedFramework = await detectFrameworkConfigFiles(cwd)
  const isTypeScript = await isTypeScriptProject(cwd)
  const tsConfig = await getTsconfig(cwd, detectedFramework?.name === 'nuxt4'
    ? './.nuxt/tsconfig.app.json'
    : detectedFramework?.name === 'nuxt3'
      ? './.nuxt/tsconfig.json'
      : detectedFramework?.name === 'inertia' // this assume any inertia project  using this path despite there is no inertia folder
        ? './inertia/tsconfig.json'
        : isTypeScript
          ? './tsconfig.json'
          : './jsconfig.json')

currently my workaround is to temporarily remove @inertiajs/vue3 form my package.json and let it detect as normal vite project.

I'm willing to contribute but will require more input from other dev who encounter or using inertia to get a better resolution for this. My suggestion will be add flag to the init to allow override tsconfig.json path eg: pnpm dlx shadcn-vue@latest init --config"./my/path/tsconfig.json"

System Info

System:
    OS: Linux 6.12 Pop!_OS 22.04 LTS
    CPU: (14) x64 Intel(R) Core(TM) Ultra 5 125U
    Memory: 5.65 GB / 15.13 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 24.15.0 - /home/noxasch/.local/share/mise/installs/node/24.15.0/bin/node
    Yarn: 4.9.2 - /home/noxasch/.local/share/mise/installs/yarn/4.9.2/bin/yarn
    npm: 11.12.1 - /home/noxasch/.local/share/mise/installs/node/24.15.0/bin/npm
    pnpm: 10.33.0 - /home/noxasch/.local/share/mise/installs/pnpm/10.33.0/pnpm
    Deno: 2.7.12 - /home/noxasch/.local/share/mise/installs/deno/2.7.12/bin/deno
  Browsers:
    Brave Browser: 148.1.90.122
    Firefox: 150.0.3
    Firefox Developer Edition: 150.0.3
  npmPackages:
    @vueuse/core: ^14.3.0 => 14.3.0 
    vue: ^3.5.34 => 3.5.34

Contributes

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions