Quantcast
Channel: How to import my own class into Nodejs - Stack Overflow
Viewing all articles
Browse latest Browse all 2

How to import my own class into Nodejs

$
0
0

I create simple class (mymodule.ts):

export module MyModule {export class MyClass  {    Name: string;    greet() {        return "Hello world!";    }         }}

So, i have server.ts class (nodejs):

import http = require('http');import my = require("mymodule");var test=new my.MyModule.MyClass();test.greet();port = process.env.port || 1337http.createServer(function (req, res) {    res.writeHead(200, { 'Content-Type': 'text/plain' });res.end('Hello World\n');}).listen(port);

But, i have error: Error TS2307 Cannot find module 'mymodule'.

I am new into node and typescript (C# background), so can you help me: how to include my own class into another class at nodejs?

Thank you!


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles



Latest Images