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

Cannot preview after nuxt build #117

Open
krank56 opened this issue Jul 6, 2022 · 11 comments
Open

Cannot preview after nuxt build #117

krank56 opened this issue Jul 6, 2022 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@krank56
Copy link

krank56 commented Jul 6, 2022

I get this error when trying to run the bundled nuxt app
[nuxt] [request error] Cannot find module '[mypath]\Frontend\.output\server\node_modules\graphql\language\parser' imported from [mypath]\Frontend\.output\server\chunks\server.mjsDid you mean to import graphql/language/parser.js? at new NodeError (node:internal/errors:372:5) at finalizeResolution (node:internal/modules/esm/resolve:437:11) at moduleResolve (node:internal/modules/esm/resolve:1009:10) at defaultResolve (node:internal/modules/esm/resolve:1218:11) at ESMLoader.resolve (node:internal/modules/esm/loader:580:30) at ESMLoader.getModuleJob (node:internal/modules/esm/loader:294:18) at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40) at link (node:internal/modules/esm/module_job:78:36)
I did follow the Quick start guide, yarn dev works fine the preview throws the error above

@Diizzayy
Copy link
Owner

Diizzayy commented Jul 8, 2022

@krank56 would you be able to provide a simple reproduction where this error occurs with the build?

I've been unable to replicate it on the demo app, you can have a look at my config below.


  • Operating System: Linux
  • Node Version: v16.15.1
  • Nuxt Version: 3.0.0-rc.4
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: modules, runtimeConfig
  • Runtime Modules: [email protected]
  • Build Modules: -

@denis-gorin
Copy link

The same error on plain nuxt-graphql-client-demo installation

[nuxt] [request error] Cannot find module 'C:\[mypath]\nuxt-graphql-client-demo\.output\server\node_modules\graphql\language\parser' imported from C:\[mypath]\nuxt-graphql-client-demo\.output\server\chunks\server.mjs

Did you mean to import graphql-client-demo/node_modules/graphql/language/parser.js?

at new NodeError (node:internal/errors:372:5)
...

the same configurations except Operating System - Windows and yarn v 1.22.19

  • Operating System: Linux
  • Node Version: v16.15.1
  • Nuxt Version: 3.0.0-rc.4
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: modules, runtimeConfig
  • Runtime Modules: [email protected]
  • Build Modules: -

steps to reproduce

  • yarn install
  • yarn build

catch error:


yarn run v1.22.19
$ nuxi build
Nuxt CLI v3.0.0-rc.4                                                                                                                                                                                                                                 14:30:40

 ERROR  (node:825780) ExperimentalWarning: buffer.Blob is an experimental feature. This feature could change at any time                                                                                                                             14:30:48
(Use `node --trace-warnings ...` to show where the warning was created)

i Vite client warmed up in 2446ms                                                                                                                                                                                                                    14:30:52
i Client built in 3882ms                                                                                                                                                                                                                             14:30:54
i Building server...                                                                                                                                                                                                                                 14:30:54
√ Server built in 1134ms                                                                                                                                                                                                                             14:30:55
√ Generated public .output/public                                                                                                                                                                                                              nitro 14:30:55
start Building server...                                                                                                                                                                                                                       nitro 14:30:55

 ERROR  (node:825780) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./public/" in the "exports" field module resolution of the package at C:\[mypath]\nuxt-graphql-client-demo\node_modules\extract-files\package.json imported from C:\[mypath]\nuxt-graphql-client-demo\node_modules.
Update this package.json to use a subpath pattern like "./public/*".

start Writing server bundle...                                                                                                                                                                                                                 nitro 14:31:01
√ Server built                                                                                                                                                                                                                                 nitro 14:31:02
  ├─ .output/server/package.json (454 B) (236 B gzip)
  ├─ .output/server/index.mjs (452 B) (253 B gzip)
  ├─ .output/server/chunks/server.mjs.map (221 kB) (31.9 kB gzip)
  ├─ .output/server/chunks/server.mjs (195 kB) (46.1 kB gzip)
  ├─ .output/server/chunks/renderer.mjs.map (1.92 MB) (91.3 kB gzip)
  ├─ .output/server/chunks/renderer.mjs (431 kB) (98.7 kB gzip)
  ├─ .output/server/chunks/node-server.mjs.map (58.4 kB) (4.41 kB gzip)
  ├─ .output/server/chunks/node-server.mjs (16.1 kB) (5.2 kB gzip)
  ├─ .output/server/chunks/client.manifest.mjs.map (376 B) (249 B gzip)
  └─ .output/server/chunks/client.manifest.mjs (314 B) (210 B gzip)
Σ Total size: 3.73 MB (475 kB gzip)
√ You can preview this build using node .output/server/index.mjs             
  • yarn start

@Diizzayy
Copy link
Owner

Diizzayy commented Jul 8, 2022

@krank56 @denis-gorin Thank you for raising this issue and providing the relevant details.

This appears to be an upstream bug with the nuxt 3 production server bundle on windows. We're looking into it and will address this as soon as possible.

@Diizzayy Diizzayy self-assigned this Jul 21, 2022
@PrinceEntree8
Copy link

PrinceEntree8 commented Aug 6, 2022

Hello, it seems that using Nuxt v3.0.0-rc.6, the error still persists

  • Operating System: Windows 10 Pro 21H1
  • Node Version: v16.156.0
  • Nuxt Version: 3.0.0-rc.6
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: modules
  • Runtime Modules: [email protected]
yarn run v1.22.19
$ nuxi build
Nuxt CLI v3.0.0-rc.6                                                                                                                                                       18:38:01
i Client built in 10332ms                                                                                                                                                  18:38:19
i Building server...                                                                                                                                                       18:38:19

 WARN  @fortawesome/fontawesome-free doesn't appear to be written in CJS, but also doesn't appear to be a valid ES module (i.e. it doesn't have "type": "module" or an .mjs extension
 for the entry point). Please contact the package author to fix.

√ Server built in 5230ms                                                                                                                                                   18:38:24
√ Generated public .output/public                                                                                                                                    nitro 18:38:25
start Building server...                                                                                                                                             nitro 18:38:27

 ERROR  (node:6456) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./public/" in the "exports" field module resolution of the package at C:\[mypath]\frontend\node_modules\extract-files\package.json imported from C:\[mypath]\frontend\node_modules.
Update this package.json to use a subpath pattern like "./public/*".
(Use `node --trace-deprecation ...` to show where the warning was created)

start Writing server bundle...                                                                                                                                       nitro 18:38:35
√ Server built                                                                                                                                                       nitro 18:38:36
  ├─ .output/server/package.json (595 B) (292 B gzip)
  ├─ .output/server/index.mjs (452 B) (253 B gzip)
  ├─ .output/server/chunks/stages.79b17bdd.mjs.map (2.09 kB) (805 B gzip)
  ├─ .output/server/chunks/stages.79b17bdd.mjs (2.4 kB) (966 B gzip)
  ├─ .output/server/chunks/server.mjs.map (670 kB) (87.2 kB gzip)
  ├─ .output/server/chunks/server.mjs (676 kB) (131 kB gzip)
  ├─ .output/server/chunks/renderer.mjs.map (1.92 MB) (91.4 kB gzip)
  ├─ .output/server/chunks/renderer.mjs (431 kB) (98.6 kB gzip)
  ├─ .output/server/chunks/node-server.mjs.map (63.2 kB) (4.46 kB gzip)
  ├─ .output/server/chunks/node-server.mjs (138 kB) (30.9 kB gzip)
  ├─ .output/server/chunks/index.8c2a10ff.mjs.map (1.98 kB) (771 B gzip)
  ├─ .output/server/chunks/index.8c2a10ff.mjs (2.51 kB) (959 B gzip)
  ├─ .output/server/chunks/index.53596502.mjs.map (1.5 kB) (658 B gzip)
  ├─ .output/server/chunks/index.53596502.mjs (1.87 kB) (812 B gzip)
  ├─ .output/server/chunks/error-component.3c5fa1a2.mjs.map (2.4 kB) (866 B gzip)
  ├─ .output/server/chunks/error-component.3c5fa1a2.mjs (2.44 kB) (1.03 kB gzip)
  ├─ .output/server/chunks/error-500.1b5f344e.mjs.map (1.79 kB) (683 B gzip)
  ├─ .output/server/chunks/error-500.1b5f344e.mjs (3.21 kB) (1.4 kB gzip)
  ├─ .output/server/chunks/error-404.fb6cd884.mjs.map (2.53 kB) (919 B gzip)
  ├─ .output/server/chunks/error-404.fb6cd884.mjs (4.09 kB) (1.69 kB gzip)
  ├─ .output/server/chunks/default.921c189e.mjs.map (19.1 kB) (3.5 kB gzip)
  ├─ .output/server/chunks/default.921c189e.mjs (30.7 kB) (8.72 kB gzip)
  ├─ .output/server/chunks/client.manifest.mjs.map (14.6 kB) (955 B gzip)
  ├─ .output/server/chunks/client.manifest.mjs (20.7 kB) (5.33 kB gzip)
  ├─ .output/server/chunks/_id_.c7b50a29.mjs.map (1.67 kB) (694 B gzip)
  └─ .output/server/chunks/_id_.c7b50a29.mjs (1.91 kB) (836 B gzip)
Σ Total size: 5.4 MB (814 kB gzip)
√ You can preview this build using node .output/server/index.mjs                                                                                                     nitro 18:38:37  
Done in 35.74s.

Update

Seems that is a common problem when bundling Nuxt 3 under Windows OSes.

I've managed to solve this issue using WSL and Docker

WSL

  1. Open a terminal in your project folder
  2. Run wsl or wsl -d <distro-name> (ex. wsl -d Fedora)
  3. Install node (and yarn optionally) sudo dnf install nodejs or sudo apt install nodejs
  4. Make sure to delete node_packages or it won't work!
  5. Run npm install -g nuxi and npm install (I'm using nuxi-cli because nuxt won't compile)
  6. Finally run nuxi build

@Diizzayy
Copy link
Owner

Diizzayy commented Aug 9, 2022

Seems that is a common problem when bundling Nuxt 3 under Windows OSes.

@PrinceEntree8 Indeed, this issue solely exists in the windows environment due to the way bundling occurs in current versions of Nuxt 3. I'll continue to keep a close eye on this one and update the status here accordingly.

Hopefully though, we can have this resolved and working properly on Windows in the near future.

@Diizzayy Diizzayy added the bug Something isn't working label Aug 9, 2022
@mateuszkulpa
Copy link

Hello,
I found an alternative workaround for this issue. After build, you should use --experimental-specifier-resolution=node flag to start your app.

node --es-module-specifier-resolution=node .output/server/index.mjs

I believe this issue is caused by import of graphql/language/parser without .mjs extension in output chunks.

@khelil
Copy link

khelil commented Jun 1, 2023

Any news on this ? I'm having the issue deploying to WP Engine Atlas.

@maximilliangeorge
Copy link

maximilliangeorge commented Jun 13, 2023

@PrinceEntree8 Indeed, this issue solely exists in the windows environment due to the way bundling occurs in current versions of Nuxt 3. I'll continue to keep a close eye on this one and update the status here accordingly.

Just thought I'd mention that I'm seeing this error on macOS also. Let me know if I can provide any supporting information, I'd be happy to help.

@PrinceEntree8
Copy link

@PrinceEntree8 Indeed, this issue solely exists in the windows environment due to the way bundling occurs in current versions of Nuxt 3. I'll continue to keep a close eye on this one and update the status here accordingly.

Just thought I'd mention that I'm seeing this error on macOS also. Let me know if I can provide any supporting information, I'd be happy to help.

Hello @maximilliangeorge, I personally use both platforms (MacOS and Windows) and I never encounter it.
Can you provide a log and more details on your setup?

1 similar comment
@PrinceEntree8
Copy link

@PrinceEntree8 Indeed, this issue solely exists in the windows environment due to the way bundling occurs in current versions of Nuxt 3. I'll continue to keep a close eye on this one and update the status here accordingly.

Just thought I'd mention that I'm seeing this error on macOS also. Let me know if I can provide any supporting information, I'd be happy to help.

Hello @maximilliangeorge, I personally use both platforms (MacOS and Windows) and I never encounter it.
Can you provide a log and more details on your setup?

@maximilliangeorge
Copy link

maximilliangeorge commented Jun 13, 2023

Sure. Build works fine, but when I try running the server as per the output You can preview this build using node server/output/server/index.mjs I get the following error.

The workaround mentioned above allows me to run the server.

My system:

  • Operating System: Darwin
  • Node Version: v16.13.1
  • Nuxt Version: 3.4.3
  • Nitro Version: 2.4.1
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: app, modules, css, components, runtimeConfig, piniaPersistedstate, graphql-client, vite, nitro
  • Runtime Modules: @pinia/[email protected], @pinia-plugin-persistedstate/[email protected], [email protected]
  • Build Modules: -

``
maximillian@mac nuxt % node server/output/server/index.mjs
node:internal/process/esm_loader:94
internalBinding('errors').triggerUncaughtException(
^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '***/nuxt/server/output/server/node_modules/graphql/language/parser' imported from ***/nuxt/server/output/server/index.mjs
Did you mean to import graphql/language/parser.js?
at new NodeError (node:internal/errors:371:5)
at finalizeResolution (node:internal/modules/esm/resolve:416:11)
at moduleResolve (node:internal/modules/esm/resolve:932:10)
at defaultResolve (node:internal/modules/esm/resolve:1044:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
at ModuleWrap. (node:internal/modules/esm/module_job:76:40)
at link (node:internal/modules/esm/module_job:75:36) {
code: 'ERR_MODULE_NOT_FOUND'
}

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

No branches or pull requests

7 participants