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

nuxi preview after nuxi generate raises an error #21728

Closed
fabon-f opened this issue Jun 23, 2023 · 6 comments
Closed

nuxi preview after nuxi generate raises an error #21728

fabon-f opened this issue Jun 23, 2023 · 6 comments

Comments

@fabon-f
Copy link

fabon-f commented Jun 23, 2023

Environment

Nuxi 3.6.0

RootDir: /home/projects/github-tehgwa
Nuxt project info:

------------------------------
- Operating System: Linux
- Node Version:     v16.20.0
- Nuxt Version:     3.6.0
- Nitro Version:    2.5.1
- Package Manager:  npm@9.4.2
- Builder:          vite
- User Config:      -
- Runtime Modules:  -
- Build Modules:    -
------------------------------

Reproduction

https://stackblitz.com/edit/github-tehgwa?file=nuxt.config.ts

Describe the bug

In nuxt 3.6.0, nuxi generate && nuxi preview raises an error. In 3.5.3 it works fine.

Nuxi 3.6.0
ℹ Node.js version: 16.20.0
ℹ Preset: node-server
ℹ Working dir: .output
ℹ Loading .env. This will not be loaded when running the server in production.
ℹ Starting preview command: node ./server/index.mjs

Error: Cannot find module '/home/projects/github-tehgwa/.output/server/index.mjs'
    at InternalError (https://githubtehgwa-uzvf.w-corp.staticblitz.com/blitz.a19575a2.js:35:384263)
    at Module._resolveFilename (https://githubtehgwa-uzvf.w-corp.staticblitz.com/blitz.a19575a2.js:35:257239)
    at Module._load (https://githubtehgwa-uzvf.w-corp.staticblitz.com/blitz.a19575a2.js:35:254647)
    at executeUserEntryPoint (https://githubtehgwa-uzvf.w-corp.staticblitz.com/blitz.a19575a2.js:35:1158713)
    at  (https://githubtehgwa-uzvf.w-corp.staticblitz.com/blitz.a19575a2.js:35:2323395)
    at _0x1d1bc2 (https://githubtehgwa-uzvf.w-corp.staticblitz.com/blitz.a19575a2.js:37:38202)
    at _0x262138 (https://githubtehgwa-uzvf.w-corp.staticblitz.com/blitz.a19575a2.js:42:92762)
    at _0x2c0031 (https://githubtehgwa-uzvf.w-corp.staticblitz.com/blitz.a19575a2.js:61:2466)
    at run (https://githubtehgwa-uzvf.w-corp.staticblitz.com/blitz.a19575a2.js:61:956) {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

 ERROR  Command failed with exit code 1: node ./server/index.mjs

  at makeError (node_modules/nuxi/dist/shared/nuxi.e25041ef.mjs:634:11)
  at handlePromise (node_modules/nuxi/dist/shared/nuxi.e25041ef.mjs:1123:35)

Perhaps nuxi preview only supports build officially, but I hope it works with generate.

Additional context

No response

Logs

No response

@flashmancheg
Copy link

flashmancheg commented Jun 24, 2023

Same here:

> nuxt preview

Nuxi 3.6.0                                                                                                                                                                                                                             6:12:34 AM
ℹ Node.js version: 18.16.1                                                                                                                                                                                                             6:12:35 AM
ℹ Preset: node-server                                                                                                                                                                                                                  6:12:35 AM
ℹ Working dir: .output                                                                                                                                                                                                                 6:12:35 AM
ℹ Loading .env. This will not be loaded when running the server in production.                                                                                                                                                         6:12:35 AM
ℹ Starting preview command: node ./server/index.mjs                                                                                                                                                                                    6:12:35 AM
                                                                                                                                                                                                                                       6:12:35 AM
node:internal/modules/cjs/loader:1080
  throw err;
  ^

Error: Cannot find module '/app/.output/server/index.mjs'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.16.1

 ERROR  Command failed with exit code 1: node ./server/index.mjs                                                                                                                                                                       6:12:35 AM

  at makeError (node_modules/nuxi/dist/shared/nuxi.e25041ef.mjs:619:11)
  at handlePromise (node_modules/nuxi/dist/shared/nuxi.e25041ef.mjs:1108:26)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async Object.invoke (node_modules/nuxi/dist/chunks/preview.mjs:77:5)
  at async _main (node_modules/nuxi/dist/cli.mjs:48:20)```

@danielroe
Copy link
Member

There is a PR open to fix this upstream in nitro.

nitrojs/nitro#1342

@some-user123
Copy link

How can this be worked around?

Copy link
Member

You can simply run npx serve .output/public to test your site locally.

@lukas-a-brand
Copy link

Still present in 3.6.1. [:
Thanks for the workaround hint @danielroe!

Copy link
Member

Sorry, I should have made clearer that this is resolved on Nuxt's edge channel (which also uses nitropack-edge), or in Nitropack's next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants