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

"This module cannot be imported in server runtime" error on fresh Nuxt install #348

Closed
alkstal opened this issue Jan 17, 2024 · 5 comments · Fixed by #349
Closed

"This module cannot be imported in server runtime" error on fresh Nuxt install #348

alkstal opened this issue Jan 17, 2024 · 5 comments · Fixed by #349
Assignees
Labels
bug Something isn't working

Comments

@alkstal
Copy link

alkstal commented Jan 17, 2024

Version

nuxt-security: 1.0.0
nuxt: 3.9.3

Reproduction Link

https://github.com/johanalkstal/nuxt-security-repro

Steps to reproduce

Run pnpm install
Run pnpm run dev

What is Expected?

No errors

What is actually happening?

Nuxt 3.9.3 with Nitro 2.8.1                                                                                 3:41:14 PM
                                                                                                            3:41:14 PM
  ➜ Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

  ➜ DevTools: press Shift + Alt + D in the browser (v1.0.8)                                                 3:41:15 PM

ℹ Vite server warmed up in 870ms                                                                           3:41:17 PM
ℹ Vite client warmed up in 1043ms                                                                          3:41:17 PM

[3:41:17 PM]  ERROR  This module cannot be importedin server runtime. [importing @nuxt/kit from node_modules/.pnpm/nuxt-security@1.0.0/node_modules/nuxt-security/dist/runtime/nitro/plugins/05-cspSsgPresets.mjs]
@alkstal alkstal added the bug Something isn't working label Jan 17, 2024
@vejja
Copy link
Collaborator

vejja commented Jan 17, 2024

@Baroshem
This is the same issue with importing @nuxt/kit in the nitro plugin
@pi0 has now implemented guards against this in Nuxt 3.9.3
Maybe we need to temporarily disable 05-cpsSsgPresets while we look for an alternative ?

@Baroshem
Copy link
Owner

Hey @vejja

Yes, it is related to that.

Could you create a fix for that? I will publish a patch version later today that we will fix with 1.1.0

@vejja vejja self-assigned this Jan 17, 2024
vejja added a commit that referenced this issue Jan 17, 2024
@vejja vejja mentioned this issue Jan 17, 2024
6 tasks
@nicokempe
Copy link

Thank you for your quick action 🙏🏽

@Baroshem
Copy link
Owner

Baroshem commented Jan 17, 2024

Released a 1.0.1 version where this issue should not appear anymore.

Could you please check if it is gone right now?

image

@ethikz
Copy link

ethikz commented Jan 17, 2024

@Baroshem It is gone for me now. Thank you @vejja @Baroshem

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

Successfully merging a pull request may close this issue.

5 participants