feathersjs/docs

Comment: Authentication (guides/basics/authentication.md)

newthings4learning opened this issue · 3 comments

Comment/Problem

// Establish a Socket.io connection
const socket = io();

This line fails. It says:
`C:\SelfLearning\feathersJS\mychatv2\src\app.js:2
const socket = io();
^

ReferenceError: io is not defined
at Object. (C:\SelfLearning\feathersJS\mychatv2\src\app.js:2:16)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (C:\SelfLearning\feathersJS\mychatv2\src\index.js:3:13)
at Module._compile (internal/modules/cjs/loader.js:689:30)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! knowledgebot@0.0.0 start: node src/
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the knowledgebot@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

System configuration (optional)

Tell us about the applicable parts of your setup.

Module versions (especially the part that's not working):

NodeJS version:
v10.14.2

Operating System:
Windows 10 Enterprise

Browser Version:
Version 80.0.3987.132 (Official Build) (64-bit)

React Native Version:

Module Loader:

io is not defined, missing import.

daffl commented

You need to update the HTML page (public/index.html) as shown in https://docs.feathersjs.com/guides/basics/authentication.html#browser-authentication. The <script src="/socket.io/socket.io.js"></script> part is specifically important. If the page is running on a different server it needs to be changed to <script src="http://localhost:3030/socket.io/socket.io.js"></script>