question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript emitted no output

See original GitHub issue

Expected Behaviour

Get compiled js from ts

Actual Behaviour

Getting the following error:

Module build failed: Error: Typescript emitted no output for C:\xampp\htdocs\node-api\src\js\server.ts. at successLoader (C:\xampp\htdocs\node-api\node_modules\ts-loader\dist\index.js:39:15) at Object.loader (C:\xampp\htdocs\node-api\node_modules\ts-loader\dist\index.js:21:12) at eval (webpack:///./src/js/server.ts?:1:7) at Object…/src/js/server.ts (C:\xampp\htdocs\node-api\dist\js\server.js:81:1) at webpack_require (C:\xampp\htdocs\node-api\dist\js\server.js:20:30) at C:\xampp\htdocs\node-api\dist\js\server.js:69:18 at Object.<anonymous> (C:\xampp\htdocs\node-api\dist\js\server.js:72:10) at Module._compile (module.js:652:30) at Object.Module._extensions…js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3)

Steps to Reproduce the Problem

Use npm run dev in the repository below. Or use the following config files:

Webpack:

const path = require( 'path' ),
	CleanWebpackPlugin = require( 'clean-webpack-plugin' );

module.exports = env => {
	return {
		mode: env.dev ? 'development' : 'production',
		entry: {
			'server': './src/js/server.ts'
		},
		output: {
			path: __dirname,
			filename: './dist/js/[name].js',
		},
		externals: '/node_modules',
		module: {
			rules: [
				{
					test: /\.js$/,
					exclude: ['/node_modules/', '/src/scss/'],
					use: [
						'babel-loader'
					]
				},
				{
					test: /\.ts(x?)$/,
					exclude: ['/node_modules/', '/src/scss/'],
					use: [
						'babel-loader',
						'ts-loader',
					]
				},
				{
					test:  /\.json$/,
					loader: 'json-loader'
				},
			]
		},
		resolve: {
			extensions: ['.js', '.ts', '.tsx'],
			alias: {
				'@': path.resolve(__dirname, './src/js')
			}
		},
		plugins: [
			new CleanWebpackPlugin(['./dist/js', './dist/css']),
		]
	}
};

Typescript:

{
	"compilerOptions": {
		"removeComments": true,
		"preserveConstEnums": true,
		"allowJs": true,
		"outDir": "./dist/js",
		"target": "es5",
		"moduleResolution": "node",
		"module": "es2015",
		"lib": [
			"es2015",
			"es2016"
		]
	},
	"exclude": [
		"./node_modules"
	]
}

Babel:

{
	"presets": [
		[
			"env", {
				"targets": {
					"node": "current"
				}
			}
		],
		"stage-2",
		"es2015"
	],
	"plugins": ["dynamic-import-node"]
}

Location of a Minimal Repository that Demonstrates the Issue.

https://github.com/SuperDJ/node-api

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

271reactions
ChuckJonascommented, May 13, 2019

I ran into this error when I had "noEmit": true, in my tsconfig.json

52reactions
eric-burelcommented, Mar 3, 2020

For lost googlers: noEmit: true mistake can happen when easily when you try to reuse a Next.js TypeScript config. Next do not need to actually emit the JS file and uses the tsconfig internally. But if you try to reuse your base config for external tooling, eg Storybook, building a server and so on, don’t forget to add noEmit: false to the extended config.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack with typescript getting TypeScript emitted no output ...
src/Api.ts: export class Api { ... } But when I run webpack I get: Error: TypeScript emitted no output for Api.ts. typescript ·...
Read more >
Webpack with typescript getting TypeScript emitted no output ...
I've got this configuration from https://www.npmjs.com/package/ts-loader: webpack.config.js: var path = require('path'); var webpack = require('webpack'); ...
Read more >
webpack/webpack - Gitter
src/app.ts Module build failed: Error: Typescript emitted no output for /Users/administrator/WebstormProjects/TypescriptFifthApp/src/app.ts at Object.loader ...
Read more >
Error: TypeScript emitted no output for - CSDN博客
ERROR in ./src/index.tsxModule build failed (from ./node_modules/ts-loader/index.js):Error: TypeScript emitted no output for ...
Read more >
ts-loader - npm
This is the TypeScript loader for webpack. ... but doing so leaves you without type checking and will not output declaration files.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found