Skip to content
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

Adding the plugin to a Vite project with AdonisJS and Inertia cause an error #2518

Open
kamilcglr opened this issue Nov 3, 2024 · 2 comments
Labels
bug Something isn't working triage v3 #1289

Comments

@kamilcglr
Copy link

kamilcglr commented Nov 3, 2024

Environment

  • Operating System: Darwin
  • Node Version: v22.11.0
  • Nuxt Version: -
  • CLI Version: 3.15.0
  • Nitro Version: -
  • Package Manager: [email protected]
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Version

Commit 845f85a

Reproduction

After creating a fresh AdonisJS project with the Inertia and Vue 3 starter kit

# Vue without server-side rendering
npm init adonisjs@latest -- -K=inertia --adapter=vue --no-ssr

Here is the procedure followed to add NuxtUI to the project https://ui3.nuxt.dev/getting-started/installation/vue

  1. Install the package with the latest commit, as the release has not yet been made
npm install https://pkg.pr.new/@nuxt/ui@5a9511f
  1. Add the Nuxt UI Vite plugin in the vite.config.ts
import ui from '@nuxt/ui/vite'
import { defineConfig } from 'vite'
import { getDirname } from '@adonisjs/core/helpers'
import inertia from '@adonisjs/inertia/client'
import vue from '@vitejs/plugin-vue'
import adonisjs from '@adonisjs/vite/client'

export default defineConfig({
  plugins: [
    inertia({ ssr: { enabled: false } }),
    vue(),
    adonisjs({ entrypoints: ['inertia/app/app.ts'], reload: ['resources/views/**/*.edge'] }),
    ui(),
  ],

  resolve: {
    alias: {
      '~/': `${getDirname(import.meta.url)}/inertia/`,
    },
  },
})

Here I already have a problem: I can't launch the application.

failed to load config from /Users/kamil/Documents/projects/myproject/vite.config.ts
TypeError: The URL must be of scheme file

There is no problem with the use of the library with a Vite et Vue project alone.

It seems to be a problem with Vite or AdonisJS, but the error is not very explicit. I tried with Node 18, 20 and 22.

Here is the Replit to reproduce
https://replit.com/@kamilcaglarcont/Adonis-x-Inertia-x-Vue-3-x-Nuxt-UI?v=1

Description

Hi, a few days weeks ago, the Nuxt UI 3 team made the component library compatible with standalone Vue projects. Thank you for your work on this library 👏 !

I'd like to use it with AdonisJS and Inertia.

AdonisJS is a TypeScript-first web framework for building web apps and API servers. It is possible to use it with Inertia to build single-page apps with VueJS.

However, I've never managed to use them together, despite several hours of debugging. I have an error that seems to be related to Vite.

Additional context

I tried with node 18, 20 and 22.

Logs

[ info ] starting HTTP server...
Debugger attached.
failed to load config from /Users/kamil/Documents/projects/myproject/vite.config.ts

   TypeError: The URL must be of scheme file

No more logs even with DEBUG=vite:*

@kamilcglr kamilcglr added bug Something isn't working triage v3 #1289 labels Nov 3, 2024
@thansil-emst
Copy link

thansil-emst commented Nov 7, 2024

I created a pure Vue project with the new Nuxt/ui alpha version released today https://github.com/nuxt/ui/releases/tag/v3.0.0-alpha.8 ,and encountered the same issue there. " TypeError: The URL must be of scheme file" It doesn't belong to AdonisJS;

@benjamincanac benjamincanac mentioned this issue Nov 8, 2024
11 tasks
@UnluckyNinja
Copy link

On windows it will log stack trace.
And a fresh vite vue-ts project with only [email protected] installed will throw this error.

Reprod: https://stackblitz.com/edit/vitejs-vite-o3b1xm (and on stackblitz it has a different error, not sure if it's related)

The error log: (Win10, node v20.16.0 )

> [email protected] dev D:\Code\Issues\nuxt-ui-issue
> vite

failed to load config from D:\Code\Issues\nuxt-ui-issue\vite.config.ts
error when starting dev server:
TypeError [ERR_INVALID_URL_SCHEME]: The URL must be of scheme file
    at fileURLToPath (node:internal/url:1463:11)
    at fileURLToPath (file:///D:/Code/Issues/nuxt-ui-issue/node_modules/.pnpm/[email protected]/node_modules/mlly/dist/index.mjs:1971:25)
    at pathToFileURL (file:///D:/Code/Issues/nuxt-ui-issue/node_modules/.pnpm/[email protected]/node_modules/mlly/dist/index.mjs:1974:26)
    at _resolve (file:///D:/Code/Issues/nuxt-ui-issue/node_modules/.pnpm/[email protected]/node_modules/mlly/dist/index.mjs:2108:10)
    at resolveSync (file:///D:/Code/Issues/nuxt-ui-issue/node_modules/.pnpm/[email protected]/node_modules/mlly/dist/index.mjs:2111:10)
    at resolvePathSync (file:///D:/Code/Issues/nuxt-ui-issue/node_modules/.pnpm/[email protected]/node_modules/mlly/dist/index.mjs:2121:24)
    at NuxtEnvironmentPlugin (file:///D:/Code/Issues/nuxt-ui-issue/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]_oszrptiaxabnycx7kgcp5nbomu/node_modules/@nuxt/ui/dist/unplugin.mjs:137:20)
    at file:///D:/Code/Issues/nuxt-ui-issue/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]_oszrptiaxabnycx7kgcp5nbomu/node_modules/@nuxt/ui/dist/unplugin.mjs:171:5
    at file:///D:/Code/Issues/nuxt-ui-issue/node_modules/.pnpm/[email protected]/node_modules/unplugin/dist/index.mjs:1793:32
    at file:///D:/Code/Issues/nuxt-ui-issue/vite.config.ts.timestamp-1731421177948-955f0a600f524.mjs:8:5
 ELIFECYCLE  Command failed with exit code 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage v3 #1289
Projects
None yet
Development

No branches or pull requests

3 participants