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

The "path" argument must be of type string. Received an instance of Array/undefined #515

Closed
AndreyYolkin opened this issue Sep 4, 2022 · 11 comments · Fixed by #514
Closed
Assignees
Labels
bug Something isn't working ❗ p4-important

Comments

@AndreyYolkin
Copy link
Contributor

Environment


  • Operating System: Linux
  • Node Version: v16.17.0
  • Nuxt Version: 2.16.0-27704181.7b3bab3
  • Nitro Version: 0.4.24
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: bridge, serverHandlers, devServerHandlers, buildModules
  • Runtime Modules: -
  • Build Modules: (), @nuxt/[email protected]

Reproduction

https://github.com/AndreyYolkin/nuxt-bug-path-argument

Describe the bug

When we are starting app in dev mode, something goes wrong and nuxt reporting that some package paths are broken. Some paths consist of Array, some are undefined.

Additional context

Package name in logs (@nuxt/ui-templates) appeared because I tried to wrap module resolving function in try catch to determine the broken package. Howerer, it actually didn't help a lot

Logs

ERROR  @nuxt/ui-templates The "path" argument must be of type string. Received an instance of Array                                                                                                19:24:41

  at new NodeError (node:internal/errors:387:5)
  at validateString (node:internal/validators:121:11)
  at Object.resolve (node:path:1098:7)
  at Function.Module._nodeModulePaths (node:internal/modules/cjs/loader:642:17)
  at Function.Module._resolveFilename (node:internal/modules/cjs/loader:896:37)
  at Function.resolve (node:internal/modules/cjs/helpers:108:19)
  at resolveModule (node_modules/nuxi/dist/shared/nuxi.a3ba4610.mjs:17:31)
  at importModule (node_modules/nuxi/dist/shared/nuxi.a3ba4610.mjs:40:24)
  at loadingHandler (node_modules/nuxi/dist/chunks/dev.mjs:6727:50)
  at Server.serverHandler (node_modules/nuxi/dist/chunks/dev.mjs:6733:58)


 ERROR  [unhandledRejection] The "path" argument must be of type string. Received undefined                                                                                                         19:24:41

  at new NodeError (node:internal/errors:387:5)
  at validateString (node:internal/validators:121:11)
  at Object.resolve (node:path:1098:7)
  at pathToFileURL (node:internal/url:1496:25)
  at importModule (node_modules/nuxi/dist/shared/nuxi.a3ba4610.mjs:41:17)
  at loadingHandler (node_modules/nuxi/dist/chunks/dev.mjs:6727:50)
  at Server.serverHandler (node_modules/nuxi/dist/chunks/dev.mjs:6733:58)
  at Server.emit (node:events:525:35)
  at Server.emit (node:domain:489:12)
  at parserOnIncoming (node:_http_server:980:12)
@danielroe danielroe added bug Something isn't working ❗ p4-important and removed pending triage labels Sep 4, 2022
@danielroe
Copy link
Member

danielroe commented Sep 5, 2022

I can't reproduce with your reproduction.

https://stackblitz.com/github/AndreyYolkin/nuxt-bug-path-argument

@AndrewBogdanovTSS
Copy link

AndrewBogdanovTSS commented Sep 5, 2022

I confirm that the issues appeared after upgrading to the latest bridge version. When disabling nitro the error goes away, but I still can't preview the home page
image

@nestle49
Copy link

nestle49 commented Sep 6, 2022

Same error

@wtagain
Copy link

wtagain commented Sep 7, 2022

Same error.
@danielroe
QQ截图20220907170601

@vladislav-sevostyanov
Copy link

I have the same

@alih70442
Copy link

The same one

@wilOliw
Copy link

wilOliw commented Sep 8, 2022

+1

*upd:
builder - nitro

@phoenix-ru
Copy link

In case you can't preview the home page, it is related to your user-defined middleware. I honestly have no idea why, but in the end you should have something like this:

// server/middleware/yourMiddleware.ts

import { defineMiddleware } from 'h3'

export default defineMiddleware((req, res, next) => {
  // your code
  next()
}

You could try to omit the next argument as recommended by h3 docs, but for me it made the middleware fire randomly, while I certainly need it on every request

@thisismydesign
Copy link

thisismydesign commented Sep 8, 2022

To revert to a working version: yarn add [email protected]

@AndrewBogdanovTSS
Copy link

@phoenix-ru I don't have any custom middleware defined but still I can't see the home page

@AndrewBogdanovTSS
Copy link

OMG, I was simply missing index.vue in pages folder, what a facepalm moment 🤦‍♂️🤦‍♂️🤦‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ❗ p4-important
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants