juniperWhite
juniperWhite

Reputation: 77

io is not defined in nodejs

My io is undefined, what are possible reasons for this?

arduino.js

var debug = require('debug')('arduino');
var five = require('johnny-five');
var socket = io();

index.js

var debug = require('debug')('server');
var express = require('express');
var http = require('http');
var socketIo = require('socket.io');
var app = express();
var httpServer = http.createServer(app);
var io = socketIo(httpServer);

what could be the issue?

Upvotes: 0

Views: 401

Answers (1)

Quentin
Quentin

Reputation: 944521

io is a local variable in the index.js module.

arduino.js is a different module.

It doesn't appear to use index.js, nor does index.js appear to use it. Even if that was the case, io is a local variable that isn't exported so is not available outside the module it is defined in.

Upvotes: 3

Related Questions