1

I have folowing directory structure:

--app
  -- test
    -- server.js
  -- app.js

I try to call function in app.js which exports from server.js, i do:

var server = require("test/server");

But get error:

Error: Cannot find module 'test/server'

How can i include it correctly?

Thank you.

1 Answer 1

4

The path must be relative to the file you are currently in.

Use var server = require("./test/server");

1
  • 2
    @0xAX You should select this as the correct answer if it worked and there's nothing else to add.
    – Sly
    Commented Jun 7, 2013 at 20:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.