Emit skipped when parsing config typescript files
Asked Answered
I

4

7

I have a problem with the node-config library while using typescript.
My config folder is as follows:
enter image description here
However after I run tsc and try to start my app from it's entry point (app.js) I get the following error:
Error: Cannot parse config file: '..../config/development.ts': TypeError: config/development.ts: Emit skipped

When deleting the typescript files from that folder and keeping only the .js files it works. Anybody has an idea how I can solve this?

This is how my tsconfig looks:

 "target": "es6" 
 "module": "commonjs"
 "strict": true
 "esModuleInterop": true


Any help would be appreciated, thanks!

Instant answered 25/9, 2019 at 9:20 Comment(5)
For whoever sees this in the future, the issue was indeed in the ts-node libraryInstant
And how would you resolve this issue??Marleah
Put the config folder inside of the src folderInstant
Update on the original post: nowadays I just use the config folder in parallel to src but the files inside of the config folder i keep .js, I don't really need type checking there so it's kinda fine, hopefully the issue in ts-node will be resolved soon.Instant
Update on the update, apparently this fixes the issue in ts-node above 0.10 github.com/TypeStrong/ts-node/issues/693#issuecomment-889531876Instant
S
8

TypeScript files outside of the project folder will produce an Emit skipped error. I can't tell if this is your issue because '..../config/' could be inside or outside the project. In my case, moving my configuration folder into my project worked around the bug. Blechy.

https://github.com/TypeStrong/ts-node/issues/693

Sprang answered 30/10, 2019 at 22:52 Comment(0)
L
2

I got this error for having an index.js file next to an index.ts file. I somehow rendered my TS to my rootDir source folder.

Terminal grab of error and fix:

> node --loader ts-node/esm src/index.ts

/sandbox/node_modules/ts-node/src/index.ts:944
          throw new TypeError(`${relative(cwd, fileName)}: Emit skipped`);
                ^
TypeError: src/services/index.js: Emit skipped
    at getOutput (/sandbox/node_modules/ts-node/src/index.ts:944:17)
    at Object.compile (/sandbox/node_modules/ts-node/src/index.ts:1243:30)
    at /sandbox/node_modules/ts-node/src/esm.ts:282:37
    at Generator.next (<anonymous>)
    at /sandbox/node_modules/ts-node/dist/esm.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/sandbox/node_modules/ts-node/dist/esm.js:4:12)
    at transformSource (/sandbox/node_modules/ts-node/dist/esm.js:127:16)
    at /sandbox/node_modules/ts-node/src/esm.ts:197:51
    at Generator.next (<anonymous>)
sandbox@sse-sandbox-4stfq:/sandbox$ ls src/services/
index.js  index.ts  user
sandbox@sse-sandbox-4stfq:/sandbox$ rm src/services/index.js
Liponis answered 26/10, 2021 at 19:59 Comment(0)
V
0

"allowJS": true works for me.

The forcing to chage the settings is not good, but this error has been admitted as bug. https://github.com/TypeStrong/ts-node/issues/693

Vallation answered 10/5, 2020 at 1:58 Comment(0)
Y
0

If nothing worked for you try updating ts-node to 10.7. It worked for me.

"ts-node": "^10.7.0",
Yorker answered 5/8, 2022 at 16:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.