Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
129
rated 0 times [  130] [ 1]  / answers: 1 / hits: 115551  / 7 Years ago, mon, february 27, 2017, 12:00:00

I'm trying to get started with Typescript for Electron development. After wrestling with getting typing for node and jQuery, I finally got my .ts file error free.


The problem is now that when I run my app, I get this error:


index.js:2 Uncaught ReferenceError: exports is not defined

These are the first two lines in index.js:


"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

I don't know that that line does. Typescript added it when compiling. My app works fine if I remove it.


How do I get rid of this error?


Oh and here's my tsconfig, if that's relevant.


{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"isolatedModules": false,
"jsx": "react",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": false,
"noImplicitAny": false,
"noImplicitUseStrict": false,
"removeComments": true,
"noLib": false,
"preserveConstEnums": true,
"suppressImplicitAnyIndexErrors": true
},
"exclude": [
"node_modules",
"typings/browser",
"typings/browser.d.ts"
],
"compileOnSave": true,
"buildOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}

More From » typescript

 Answers
53

There is an issue with the new version of typescript 2.2.1, try using the older version 2.1.6, that solved the exact same issue which you have for me.



Version 2.2.1 on compiling adds this line Object.defineProperty(exports, __esModule, { value: true }); while the older 2.1.6 does not.


[#58748] Saturday, February 25, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
devlin

Total Points: 474
Total Questions: 113
Total Answers: 100

Location: Sweden
Member since Fri, Apr 16, 2021
3 Years ago
;