socket.io-client module not found

Created on 2 Jan 2017  路  7Comments  路  Source: socketio/socket.io

Note: for support questions, please use one of these channels: stackoverflow or slack

You want to:

  • [x] report a bug
  • [ ] request a feature

Current behaviour

I built a simple task list with this and was able to get it to work a few months ago. I am going back to build another more robust program, but am getting this error when I try to run webpack 1.13.1:
ERROR in ./socket-listeners/task-listener.js
Module not found: Error: Cannot resolve module 'socket.io-client' in /home/ubuntu/workspace/socket-listeners
@ ./socket-listeners/task-listener.js 33:9-36

Steps to reproduce (if the current behaviour is a bug)

I have used both "import io from 'socket.io-client';" and "const io = require('socket.io-client');" and both reproduce the same error.

Expected behaviour

I was expecting it to find the module on its own. I am able to find it manually in my node_modules folder.

Setup

  • OS: not sure if this counts as I use Cloud 9. I tried to work it on my local machine using windows 10, but experienced the same result.
  • browser: chrome
  • socket.io version: 1.4.8

Other information (e.g. stacktraces, related issues, suggestions how to fix)

I'm hoping this can be fixed relatively quickly as this is going to be a final project so I can graduate. If anybody has any work-around, please let me know. Thanks!

Most helpful comment

As with @killerspaz I needed to reference socket.io-client/dist/socket.io

All 7 comments

How did you install the package? Could you share your webpack config?

The package.json nor bower.json are configured properly

@killerspaz would you know what can be improved / fixed?

Thanks, @killerspaz. That's what did the trick, just had to dig a little deeper into the socket.io module:
import io from 'socket.io/node_modules/socket.io-client';

@darrachequesne sorry, my feedback was actually meant for socket.io-client, not this project. Must have gotten switched up somehow. Upon further inspection, it looks like bower.json is missing, and written as .bower.json, but with invalid data? I'm not fully understanding what's going on there, since bower says it's grabbing from https://github.com/LearnBoost/socket.io-client.git, which my URL is redirecting to https://github.com/socketio/socket.io-client.git; but the source certainly doesn't appear to have this file. Apparently bower adds it. Utilizing debowerify fails somewhere along the line saying it can't find socket.io-client. I ended up referencing socket.io-client/dist/socket.io for it to resolve properly.

@jstrother, you can use just socket.io-client to reduce packages if you wanted. It's not really optimal or suggested to dig into a module's dependencies.

As with @killerspaz I needed to reference socket.io-client/dist/socket.io

Thanks, @killerspaz, that worked. (Sorry for being late responding)

error: Error: Unable to resolve module use-socket.io-client from App.js: use-socket.io-client could not be found within the project.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MyMomSaysIAmSpecial picture MyMomSaysIAmSpecial  路  4Comments

Elliot9 picture Elliot9  路  4Comments

thebinarypenguin picture thebinarypenguin  路  4Comments

jloa picture jloa  路  4Comments

doughsay picture doughsay  路  4Comments