[Solved] mqtt.js Error: n.createConnection is not a function

Reason: This is a version problem, 4.2.X+ (this is also the problem when I use the latest version, which may be improved in the future)

Solution: use the lower version, I use 4.1.X is OK.

Here is the output of the client after the connection is successful

Vue solution:
Vue installation. Not only the version needs to be modified, but also the ^  in front of the version needs to be removed (in packpage.json), but there is no Vue test. You can try it (a picture of other blogs is cut here)

Read More: