Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9147861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:06:17+00:00 2026-06-17T11:06:17+00:00

My nodejs Typescript server has grown in complexity and now relies on a few

  • 0

My nodejs Typescript server has grown in complexity and now relies on a few classes defined in another .ts file. This has created a strange compilation problem:

  • tsc server.ts compiles everything fine. But node server.js crashes at
    the first line that instantiates a class from the other .ts file

  • tsc --out server.js server.ts results in the error message: “module
    emit collides with emitted script”

  • tsc --out serv.js server.ts seems to work but actually compiles
    everything EXCEPT server.ts. The code from the other files is there and node serv.js just returns without any output

I’m not the only one with this error, https://typescript.codeplex.com/workitem/294 unfortunately the solution on codeplex doesn’t work for me.

How do I use tsc correctly ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:06:19+00:00Added an answer on June 17, 2026 at 11:06 am

    Your server.ts dependencies need to be modules that export their surface area with top-level export directives, and server.ts should load them using import directives. The root cause here is that TypeScript has two different sorts of universes for compilation.

    The first is the default one that you’d use for regular webpages, where some simple loader takes 1 or more source files in some fixed order and executes them in that order, and you’re on your own for dependency ordering. This is called “program” compilation. In program compilation, you might do side-by-side compilation (a.ts => a.js, b.ts => b.js), or you might do concatenated compilation using --out ((a.ts + b.ts) => out.js).

    In program compilation, you refer to your references using ///<reference> tags. If those references are to source files (.ts), they’ll get concatenated in to the output if using --out, or emitted as a side-by-side .js file otherwise. If those references are to a declaration file (.d.ts), you’re basically saying you will be getting definitions for those files loaded via the external loader (i.e. a <script> tag in the browser).

    The second is the kind of compilation you’d use for node.js or other environments that do asynchronous or idempotent module loading with runtime dependency resolution. This called “module” compilation. Here, the --module flag you pass to tsc matters, and the only valid thing to do is side-by-side compilation, because loading a single file as a module is (generally) how the module loaders in node.js, etc work.

    In module compilation, you use the export keyword on a top-level object (function, class, module, interface, or var) to control what’s available to code that refers to you using import. You should only ever have /// <reference> tags that point to .d.ts declaration files, because the module-based runtime loaders don’t have a notion of loading a naked JS file. You won’t compile with --out.

    You never want to mix and match these compilation modes, because it simply is not going to work. In fact, in 0.8.2.0, tsc will simply issue an error if you try to do this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a nodejs application which works fine in a single core. This
The nodejs server 'gets' this JSON stream from Twitter and sends it to the
I'm using Nodejs and Socket.io. When the client connects, new JavaScript objects are created.
I'm using NodeJS, express, and passport. However I think this question is just about
Nodejs version: 0.8.8 Here is the server: var http = require('http'); var port =
I have two nodejs http servers, one requests a tar file from the other.
I have this NodeJS app which fetches JSON-type response from a web application and
In nodeJS, we can get POST data by this: <input type=text name=doc[a]/> var doc
I have a NodeJs server connecting to redis. I also have a program using
I have a NodeJS server running which is sucessfully acessed by 2 domains though

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.