2

I have created this 2 files from TS language specification manual (page 111)

File geometry.ts:

export interface Point { x: number; y: number };
export function point(x: number, y: number): Point { return { x: x, y: y }; }

File game.ts:

import g = require("geometry"); var p = g.point(10, 20);

I try the following in command line:

tsc geometry.ts -d -m "commonjs"
tsc game.ts -m "commonjs"
node game.ts

I get the following error.

module.js:340
    throw err;
          ^
    Error: Cannot find module 'geometry'
        at Function.Module._resolveFilename (module.js:338:15)
        at Function.Module._load (module.js:280:25)
        at Module.require (module.js:364:17)
        at require (module.js:380:17)
        at Object.<anonymous> (C:\Temp\Temp\game.js:1:71)
        at Module._compile (module.js:456:26)
        at Object.Module._extensions..js (module.js:474:10)
        at Module.load (module.js:356:32)
        at Function.Module._load (module.js:312:12)
        at Function.Module.runMain (module.js:497:10)
1
  • You should run node game.js instead of node game.ts Commented Oct 20, 2013 at 1:07

1 Answer 1

3

Since the geometry module is in your working directory, you need to do require('./geometry') instead of require('geometry')

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.