scalar / scalar

Beautiful API references from OpenAPI/Swagger files ✨
https://scalar.com/swagger-editor
MIT License
5.65k stars 174 forks source link

Error while requiring module @scalar/nuxt: TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must be absolute #2431

Closed jonasfroeller closed 3 weeks ago

jonasfroeller commented 2 months ago

What happens?

 ERROR  Error while requiring module @scalar/nuxt: TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must be absolute                                                                     03:01:25

 ERROR  Cannot restart nuxt:  File URL path must be absolute                                                                                                                                 03:01:25

  at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
  at new NodeError (node:internal/errors:405:5)
  at getPathFromURLWin32 (node:internal/url:1450:11)
  at fileURLToPath (node:internal/url:1480:22)
  at jiti (node_modules\.pnpm\jiti@1.21.6\node_modules\jiti\dist\jiti.js:1:244150)
  at A:/xxx/xxx/node_modules/.pnpm/@scalar+nuxt@0.2.35_magicast@0.3.4_postcss@8.4.39_rollup@4.18.1_tailwindcss@3.4.4_typescript@5.5.3/node_modules/@scalar/nuxt/dist/module.mjs:1:199
  at evalModule (node_modules\.pnpm\jiti@1.21.6\node_modules\jiti\dist\jiti.js:1:247313)
  at jiti (node_modules\.pnpm\jiti@1.21.6\node_modules\jiti\dist\jiti.js:1:245241)
  at requireModule (/A:/xxx/xxx/node_modules/.pnpm/@nuxt+kit@3.12.3_magicast@0.3.4_rollup@4.18.1/node_modules/@nuxt/kit/dist/index.mjs:2233:26)
  at loadNuxtModuleInstance (/A:/xxx/xxx/node_modules/.pnpm/@nuxt+kit@3.12.3_magicast@0.3.4_rollup@4.18.1/node_modules/@nuxt/kit/dist/index.mjs:2508:92)
  at async installModule (/A:/xxx/xxx/node_modules/.pnpm/@nuxt+kit@3.12.3_magicast@0.3.4_rollup@4.18.1/node_modules/@nuxt/kit/dist/index.mjs:2460:47)
  at async initNuxt (/A:/xxx/xxx/node_modules/.pnpm/nuxt@3.12.3_@parcel+watcher@2.4.1_@types+node@20.14.10_eslint@8.57.0_ioredis@5.4.1_magicast@0_xycrqtrly3bqppfbm5yc7yejyu/node_modules/nuxt/dist/index.mjs:4486:5)
  at async NuxtDevServer._load (/A:/xxx/xxx/node_modules/.pnpm/nuxi@3.12.0/node_modules/nuxi/dist/chunks/dev2.mjs:6875:5)
  at async NuxtDevServer.load (/A:/xxx/xxx/node_modules/.pnpm/nuxi@3.12.0/node_modules/nuxi/dist/chunks/dev2.mjs:6810:7)
  at async _applyPromised (/A:/xxx/xxx/node_modules/.pnpm/nuxi@3.12.0/node_modules/nuxi/dist/chunks/dev2.mjs:3804:10)
WARN  Failed to load source map for A:/xxx/node_modules/.pnpm/parse5@7.1.2/node_modules/parse5/dist/parser/open-element-stack.js.              00:05:46  
Error: An error occurred while trying to read the map file at open-element-stack.js.map
Error: ENOENT: no such file or directory, open 'A:\xxx\node_modules\.pnpm\parse5@7.1.2\node_modules\parse5\dist\parser\open-element-stack.js.map'

WARN  [nuxt] #imports should be transformed with real imports. There seems to be something wrong with the imports plugin.

 ERROR(vue-tsc)  Cannot find module '~/src/types' or its corresponding type declarations.
 FILE  A:/xxx/node_modules/.pnpm/@scalar+nuxt@0.2.54_postcss@8.4.40_storybook@8.2.6_tailwindcss@3.4.6_typescript@5.5.4/node_modules/@scalar/nuxt/dist/runtime/components/ScalarApiReference.vue:5:36

    3 | import { ModernLayout, parse } from '@scalar/api-reference'
    4 | import { reactive, ref, toRaw } from 'vue'
  > 5 | import type { Configuration } from '~/src/types'
      |                                    ^^^^^^^^^^^^^
    6 |
    7 | import './nuxt-theme.css'
    8 |

[vue-tsc] Found 1 error. Watching for file changes.

What did you expect to happen?

The module to be requirable.

How can we reproduce the issue?

  1. run npx nuxi module add @scalar/nuxt

I tried it on Windows11 and using WSL2. I also tried npm instead of pnpm. Same issue.

OpenAPI Document

No response

ssw1992 commented 1 month ago

I meet same problem

ssw1992 commented 1 month ago

@hanspagel Don't be too indifferent, give me a rough solution first, big brother!

amritk commented 1 month ago

This looks like it might be a nuxt issue. I'll have to get my windows env setup for some testing.

https://stackoverflow.com/questions/77509937/nuxt-3-and-express-js-on-windows-absolute-paths-must-be-valid-file-urls-re

ssw1992 commented 3 weeks ago

image

This is my local npm package, as you can see, the paths indicated by the arrows are all written dead and do not exist on my computer. The error message starts from the first line