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 read properties of undefined (reading 'modules') #14802

Closed
gurpindersinghgill opened this issue Sep 4, 2022 · 23 comments
Closed

Cannot read properties of undefined (reading 'modules') #14802

gurpindersinghgill opened this issue Sep 4, 2022 · 23 comments

Comments

@gurpindersinghgill
Copy link

gurpindersinghgill commented Sep 4, 2022

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

  1. npx nuxi init nuxt-app
  2. cd nuxt-app
  3. npm install
  4. 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>
@LimonJuice322
Copy link

I have the same problem. With 3.0.0-rc.8 it works fine

@ggueyraud
Copy link

Same issue here.

@ggueyraud
Copy link

sidebase/sidebase#16 (comment)

@gurpindersinghgill
Copy link
Author

gurpindersinghgill commented Sep 7, 2022

After reinstalling. Xcode, home brew and node , it worked . Don't know where the issue origins from. I had no issues running previous rc version before reinstalling . It only caused issues on rc.9. Worth a try for others , hope it helps.

@dan-hammond
Copy link

The same thing is happening for me and my colleague on Windows. I can't recreate it in a blank project, but our actual project has this issue.

I've tried:

  • deleting package-lock.json and node_modules and reinstalling everything
  • clearing the nuxt caches
  • commenting out my module + plugin code
  • running it both natively on my machine and in a Linux docker container

When the project is built for production it runs fine.

I appreciate I'm not offering much to go on, but I'm a bit stumped as to what else to try.

@danielroe
Copy link
Member

The error message here is referring to useSSRContext().modules It seems that useSSRContext is returning null for some reason, possibly because of a mismatch of vue versions within your node_modules folder. Check your dependency tree/lockfile to ensure you have only one version of vue installed.

@dan-hammond
Copy link

Thanks for the pointer. I think I figured out which of my dependencies is doing it. For now I've just commented out the dependency in question as it's not really necessary.

I have a module project (scaffolded via npx nuxi init -t module my-module) which installs and uses particles.vue3 in the playground site, which seems to be the cause.

I wouldn't know how to go about bringing that dependency back into the project while avoiding this error, but it's not the end of the world.

Copy link
Member

If it is a vue dependency issue, you could either add that package to your build.transpile or use yarn resolutions or npm overrides to force vue version.

@Melbourneandrew
Copy link

This worked for me. Downgrading to 3.0.0-rc.8
sidebase/sidebase#16 (comment)

@BracketJohn
Copy link
Contributor

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:

❯ npm list --depth=10 | grep ' vue@'
│ └── vue@3.2.38 deduped
│ │ └── vue@3.2.38 deduped
│ └── vue@3.2.38 deduped
│ └── vue@3.2.38 deduped
│ │ └── vue@3.2.38 deduped
│ │ └── vue@3.2.38 deduped
│ ├── vue@3.2.38 deduped
│ │ │ └── vue@3.2.38 deduped
│ │ └── vue@3.2.38 deduped
│ │ └── vue@3.2.38 deduped
│ │ └── vue@3.2.38 deduped
│ └── vue@3.2.38 deduped
│ └── vue@3.2.38 deduped
├─┬ vue@3.2.38
│ │ └── vue@3.2.38 deduped

@craigharman
Copy link

I'm getting this issue also.

Strangely though, I created a new install of Nuxt 3rc9 and added my modules one by one to find the one causing the issue and they all worked. Matched the dependencies with the original project experiencing the problem and still get the 500 error.

@a1xon
Copy link

a1xon commented Sep 14, 2022

clean install of rc.9 and rc.10 fails for Ubuntu 22.04.
does not fail on windows on same machine.
tried cleaning caches, tried npm, yarn and pnpm.
vue versions are all the same.

@productdevbook
Copy link
Member

Check the vue versions in your lock file. If you see two or more different versions like vue@3.2.39 vue@3.2.37, make the same vue versions in your project.

Get all your vue versions to the latest version.

This is not a problem on the nuxt side.

@manniL
Copy link
Member

manniL commented Sep 15, 2022

@productdevbook The problem is that for some people, even the starter project fails where Vue versions should be fine.

See #14802, as well as the author of the issue.

@productdevbook
Copy link
Member

productdevbook commented Sep 15, 2022

clean install of rc.9 and rc.10 fails for Ubuntu 22.04. does not fail on windows on same machine. tried cleaning caches, tried npm, yarn and pnpm. vue versions are all the same.

@a1xon How many different vue versions do you see in the lock file?

search please @vue/runtime-core/

@brightjune
Copy link

Same error on MacBook Pro , Ubuntu 18.04.6. But it's ok on windows 11.

Node Version: v16.17.0
Nuxt Version: 3.0.0-rc.9 / 3.0.0-rc.10

@productdevbook
Copy link
Member

productdevbook commented Sep 15, 2022

Same error on MacBook Pro , Ubuntu 18.04.6. But it's ok on windows 11.

Node Version: v16.17.0 Nuxt Version: 3.0.0-rc.9 / 3.0.0-rc.10

@brightjune How many different vue versions do you see in the lock file?

search please @vue/runtime-core/

@productdevbook
Copy link
Member

image

Take a look at vue and its subversions.

@a1xon
Copy link

a1xon commented Sep 16, 2022

Same error on MacBook Pro , Ubuntu 18.04.6. But it's ok on windows 11.
Node Version: v16.17.0 Nuxt Version: 3.0.0-rc.9 / 3.0.0-rc.10

@brightjune How many different vue versions do you see in the lock file?

search please @vue/runtime-core/

One. "version": "3.2.39". It's a fresh install.

@productdevbook
Copy link
Member

Same error on MacBook Pro , Ubuntu 18.04.6. But it's ok on windows 11.
Node Version: v16.17.0 Nuxt Version: 3.0.0-rc.9 / 3.0.0-rc.10

@brightjune How many different vue versions do you see in the lock file?
search please @vue/runtime-core/

One. "version": "3.2.39". It's a fresh install.

very interesting, can you send me a lock file so I can review it ? Thank you

@teddycoder9
Copy link

I have the same problem, I install a purely new Nuxt RC10 or RC9 project and get this error.
Node 16.14.2 and Windows 11 21H2 22000.978

image

Also, I only have one @vue/runtime-core version in package-lock.json is 3.2.39

image

Here is my package-lock.json: https://www.transfernow.net/dl/20220916abOwN9Oc

@brightjune
Copy link

Same error on MacBook Pro , Ubuntu 18.04.6. But it's ok on windows 11.
Node Version: v16.17.0 Nuxt Version: 3.0.0-rc.9 / 3.0.0-rc.10

@brightjune How many different vue versions do you see in the lock file?
search please @vue/runtime-core/

One. "version": "3.2.39". It's a fresh install.

very interesting, can you send me a lock file so I can review it ? Thank you

@vue/runtime-core 3.2.39

Here is the yarn lock file, Thank you!

yarn.lock.txt

@pi0
Copy link
Member

pi0 commented Sep 16, 2022

Moving to #14952

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