Bharti Sharma
Bharti Sharma

Reputation: 81

Error: Cannot find module 'socket.io-client/dist/socket.io.min.js'

I am trying to install spika backend (node applicaton) When I tried Start server in stand alone mode with the following command: $ node src/server/main.js

I encountered this error:

Error: Cannot find module 'socket.io-client/dist/socket.io.min.js'

Node version: v8.10.0 npm version: v3.5.2

Upvotes: 4

Views: 2298

Answers (2)

UtkarshPramodGupta
UtkarshPramodGupta

Reputation: 8152

Install socket.io and not socket.io-client

socket.io-client is the client side library, not server side. You have to link it in your HTML instead of including it in your node.js file. It is socket.io library actually that is to be included server side. Read more on How To Do here.

Upvotes: 2

Willem van der Veen
Willem van der Veen

Reputation: 36630

Try running the following in the terminal at the directory of your package.json file:

npm i

npm i --save socket.io

  • npm i will install all the dependencies in your package.json file
  • If this dependency is not there you need to install it with npm i --save socket.io

Upvotes: 1

Related Questions