Hi I am new to Nodejs and I am having a problem when debugging a server example through node debugger.
This is part of server.js
, the file I'm trying to inspect.
// Babel ES6/JSX Compiler
require('babel-register');
var path = require('path');
var express = require('express');
var bodyParser = require('body-parser');
var compression = require('compression');
var favicon = require('serve-favicon');
var logger = require('morgan');
var async = require('async');
var colors = require('colors');
var mongoose = require('mongoose');
I was debugging this file on the terminal by node debug server.js
command.
When I tried to inspect the path
variable above, I've got this.
debug> path
{ resolve: [Function],
normalize: [Function],
isAbsolute: [Function],
join: [Function],
relative: [Function],
_makeLong: [Function],
dirname: [Function],
basename: [Function],
extname: [Function],
format: [Function],
parse: [Function],
sep: '/',
delimiter: ':',
posix: [Circular],
win32:
{ resolve: [Function],
normalize: [Function],
isAbsolute: [Function],
join: [Function],
relative: [Function],
_makeLong: [Function],
dirname: [Function],
basename: [Function],
extname: [Function],
format: [Function],
parse: [Function],
sep: '\\',
delimiter: ';' } }
However when I tried to inspect express
, the debugger keeps saying it's not defined. This is same to other variables like bodyParser
, compression
, etc.
debug> express
ReferenceError: express is not defined
at repl:1:1
at Object.exports.runInContext (vm.js:44:17)
at Interface.controlEval (_debugger.js:952:21)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.<anonymous> (repl.js:412:12)
at emitOne (events.js:77:13)
at REPLServer.emit (events.js:169:7)
at REPLServer.Interface._onLine (readline.js:210:10)
at REPLServer.Interface._line (readline.js:549:8)
Can someone please explain why these variables are not defined even after I used require()
? server.js
runs fine when I just execute it by node server.js
. So I don't know why the debugger says some variables that are definitely used are not defined.