nuxt: Cannot read properties of undefined (reading 'modules')
Environment
- Operating System:
Darwin - Node Version:
v16.14.0 - Nuxt Version:
3.0.0-rc.9 - Nitro Version:
0.5.0 - Package Manager:
npm@8.3.1 - Builder:
vite - User Config:
- - Runtime Modules:
- - Build Modules:
-
Reproduction
- npx nuxi init nuxt-app
- cd nuxt-app
- npm install
- npm run dev
Error is thrown only when running on macbook…
Describe the bug
Unable to run dev after fresh install on Macbook. However, doing npm run build, and npm run preview works without issue. Testing in stackblitz shows no issues however.
Additional context
Had no issues yesterday when doing fresh install of rc.9
Logs
gurpinder@Gurpinders-MacBook-Pro bug % npx nuxi init bug-test
Need to install the following packages:
nuxi
Ok to proceed? (y)
Nuxi 3.0.0-rc.9 22:28:53
ℹ cloned nuxt/starter#v3 to /Users/gurpinder/Desktop/bug/bug-test 22:28:54
22:28:54
Nuxi 3.0.0-rc.9 22:29:51
Nuxt 3.0.0-rc.9 with Nitro 0.5.0 22:29:51
22:29:54
> Local: http://localhost:3000/
> Network: http://192.168.0.106:3000/
ℹ Vite server warmed up in 171ms 22:29:55
✔ Nitro built in 185 ms nitro 22:29:55
ℹ Vite client warmed up in 701ms 22:29:55
[Vue warn]: inject() can only be used inside setup() or functional components.
[Vue warn]: Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.
[Vue warn]: Unhandled error during execution of setup function
at <NuxtRoot>
[nuxt] [request error] [unhandled] [500] Cannot read properties of undefined (reading 'modules')
at _sfc_main.setup (./node_modules/nuxt/dist/app/components/nuxt-root.vue:67:16)
at callWithErrorHandling (./node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:157:22)
at setupStatefulComponent (./node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7107:29)
at setupComponent (./node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7062:11)
at renderComponentVNode (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:172:17)
at renderToString (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:446:26)
at Object.renderToString$1 [as renderToString] (./.nuxt/dev/index.mjs:472:24)
at Object.renderToString (./node_modules/vue-bundle-renderer/dist/runtime.mjs:173:40)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async ./.nuxt/dev/index.mjs:521:21
[Vue warn]: inject() can only be used inside setup() or functional components.
[Vue warn]: Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.
[Vue warn]: Unhandled error during execution of setup function
at <NuxtRoot>
[Vue warn]: inject() can only be used inside setup() or functional components.
[Vue warn]: Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.
[Vue warn]: Unhandled error during execution of setup function
at <NuxtRoot>
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 9
- Comments: 23 (10 by maintainers)
If it is a vue dependency issue, you could either add that package to your
build.transpileor use yarn resolutions or npm overrides to force vue version.As this is also happening in https://github.com/sidestream-tech/sidebase, I’ve checked for different vue-versions there, and it looks like they are all the same:
This worked for me. Downgrading to 3.0.0-rc.8 https://github.com/sidestream-tech/sidebase/issues/16#issuecomment-1236960305
https://github.com/sidestream-tech/sidebase/issues/16#issuecomment-1236960305