Carlos Gigante
Carlos Gigante

Reputation: 53

I cannot use Websocket package on NestJS

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

Upvotes: 5

Views: 7070

Answers (5)

Fishcan
Fishcan

Reputation: 1

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

Upvotes: 0

Kamil Myśliwiec
Kamil Myśliwiec

Reputation: 9168

@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.

Upvotes: 17

song mart
song mart

Reputation: 11

I back to v.

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

is working

Upvotes: 1

Roman
Roman

Reputation: 299

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"

Upvotes: 11

erfan seidipoor
erfan seidipoor

Reputation: 91

It wokrs for me follow these steps:

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

Upvotes: 1

Related Questions