You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I open node and type following commands (same as inside server.js) I get following error:
$ node
> const TrailsApp = require('trails');
undefined
> const app = require('./');
undefined
> const server = new TrailsApp(app);
TypeError: Cannot read property 'filename' of undefined
at Function.buildConfig (/node_modules/trails/lib/Configuration.js:58:52)
at new Configuration (/node_modules/trails/lib/Configuration.js:16:31)
at TrailsApp (/horizon-core/node_modules/trails/index.js:61:16)
at repl:1:16
at sigintHandlersWrap (vm.js:22:35)
at sigintHandlersWrap (vm.js:73:12)
at ContextifyScript.Script.runInThisContext (vm.js:21:12)
at REPLServer.defaultEval (repl.js:340:29)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.<anonymous> (repl.js:538:10)
at emitOne (events.js:101:20)
at REPLServer.emit (events.js:188:7)
at REPLServer.Interface._onLine (readline.js:233:10)
at REPLServer.Interface._line (readline.js:585:8)
at REPLServer.Interface._ttyWrite (readline.js:862:14)
When I run node server.js everything is fine. It is because require.main is not defined when node is running without a script being specified. Is is an expected behaviour? It is causing us headaches when we try to use Jest for testing.
Environment
node version: v6.11.0
trails version: v2-latest
operating system: OSX Sierra 10.12
The text was updated successfully, but these errors were encountered:
This is because Trails figures out its current root directory from require.main, which is the module from which it is required. Because you're running from the node repl, there is no main module. I'm sorry you're having this issue -- we hadn't considered this use case in designing the configuration.
Try setting require.main manually before instantiating Trails, e.g.
Issue Description
When I open node and type following commands (same as inside server.js) I get following error:
When I run
node server.js
everything is fine. It is becauserequire.main
is not defined when node is running without a script being specified. Is is an expected behaviour? It is causing us headaches when we try to use Jest for testing.Environment
The text was updated successfully, but these errors were encountered: