5

I'm trying to work with websockets on Nestjs, i install the dependencies

yarn add @nestjs/websockets @nestjs/platform-socket.io

I generated a example resource for the websockets

nest g res messagesWs --no-spec

Then this message shows up in my terminal

TypeError: this.metadataScanner.getAllMethodNames is not a function

This is a capture from the problem

What can i do? PD: sorry for my bad english

I search for that function getAllMethodNames but i didn't get anything

1
  • Could you share the messageWs file and the module you added it to, please. Commented Feb 7, 2023 at 15:41

5 Answers 5

17

@nestjs/core and @nestjs/websockets versions should always be in sync. For example, if the latest version of your locally installed @nestjs/websockets package is 9.3.6, then you have to make sure that @nestjs/core is also on 9.3.6.

Once you fix this up, the error will go away.

Sign up to request clarification or add additional context in comments.

1 Comment

I assume there's no way to express such a constraint in the package file? So you have to resort to specifying exact versions in the package.json file?
11

I had the same problem. I solved it by downgrading a few versions.

From

"@nestjs/platform-socket.io": "9.3.6", "@nestjs/websockets": "9.3.6"

to

"@nestjs/platform-socket.io": "9.1.6", "@nestjs/websockets": "9.1.6"

Comments

1

It wokrs for me follow these steps:

  1. remove node_modules folder
  2. from package.json remove ^ before the version number
  3. npm install

Comments

1

I back to v.

"@nestjs/platform-socket.io": "^7.6.15",
"@nestjs/websockets": "^7.6.15",

is working

1 Comment

Thanks, i tried with 9.1.6 version and its working
0

Work for me:

Get @nestjs/core version in pnpm-lock.yaml

Then install @nestjs/platform-socket.io and @nestjs/websockets as same version of @nestjs/core

Or upgrade all packages about nestjs to latest, pnpm up

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.