Categories
JavaScript Answers

How to fix Node.js socket.io.js not found?

Spread the love

To fix Node.js socket.io.js not found, we expose the folder with socket.io.js as the static folder.

For instance, we write

app.use(express.static(path.join(__dirname, "/")));

to call express.static to expose the root folder as the static folder.

And then we can put socket.io.js there and use it in a script tag like

<script src="//socket.io.js"></script>

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.