-
-
Notifications
You must be signed in to change notification settings - Fork 534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Importing a file outside of the project folder causes: Emit skipped error #693
Importing a file outside of the project folder causes: Emit skipped error #693
Comments
@DustinJSilk Do you have an example that could be referenced? Also, what version of |
I was using version 7.0.1, with typescript 2.9.2 and without any arguments so it would have been default. I can upload an example tomorrow evening and will send you a link. I switched to compiling down with just tsc in the meantime and dont have a branch with the original ts-node setup at the moment |
I got the "Emit skipped" error when trying to compile TypeScript code which was not under the 'rootDir' (tsconfig.json). |
@bennyn Thanks for following up! Can you include the version ( |
@blakeembrey I have used the latest and greatest:
My {
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist",
"rootDir": "src",
"target": "es5"
},
"exclude": [
"dist",
"node_modules"
]
} I tried to use
I have to admit that the error message sounded a little cryptic to me so I tried to run
Now everything works like expected. 😃 |
From experimentation this appears to be happening when using |
I am getting this same error within my project.
Simply tried to do a
It's strange because we have this working with esnext as the compile target and module target and then using gulp and babel as such:
But I want to skip the gulp step, and babel altogether and compile directly down to es2015 from typescript. |
I found a combination that worked for me, something about allowJs broke it:
|
Im getting this error when I just try to add typeRoots because of this issue: #745 I add I have this tsconfig:
|
FYI: just in case this is useful some someone. using mocha + typescript + node, I received the same error, and it was because I had a .js file that got written next to the source .ts file. Presumably, even though ts-node isn't writing the .js files out, it detected that one was there and stopped. |
Also leaving a comment in case it is useful to someone: this error can also occur if you have |
i get https://github.com/bluelovers/is-req-https |
Any solution to this other than turning off |
@marchand-software Are you saying you have two files with exactly the same filename except for the file extension? For example, |
@cspotcode yes, correct. It seems easiest for my project structure to duplicate the Essentially what I'm trying to do is work backwards on my dependency graph and eventually be able to delete all the |
@marchand-software are all your require statements including file extensions? Are you doing |
@cspotcode correct again. Well, kind of... I was mistakenly using a mix of both ways you mentioned... I tried changing all Still getting the same Emit skipped error. |
@marchand-software If you change to |
@cspotcode nailed it. Thanks a bunch. I was mislead into thinking |
I have a similar problem while trying to import a When I run
|
Nice one @bennyn, that was my problem |
require('path without extension') does not work for Webpack, because webpack requires setting rules for each extensions. For example, .ts => handled by ts-loader, anything else is handled by raw loader. |
As this issue is still open I would like to share my piece. Reading this discussion I found this comment with a lot of likes; #693 (comment) which also solved my problem. How did it happen?I found that I once compiled my project without specifying an outdir that resulted in every TS file being compiled to JS files in the same path, next time I ran the project the throw a SolutionDelete every JS file with the same name in the same directory as the TS file, add Don'tDo not do ConclusionIt would be awesome if it was possible to add a error message that explained this issue so people don't have to face this issue since it can be annoying, for use those people that have |
I know we have "thumbs up" for this, but thank you @jordanrastrick ! |
The solution for me was removing rootDir |
Also fixed by removing rootDir. |
I have a repo with two packages (let's call them I use yarn workspaces to be able to use package When package I set up some tests on package
It would seem that In my case setting For now I'm glad to have a workaround. Hope this helps others and hope it sheds a light on a possible solution for the TypeScript team. Cheers |
I have the same problem as @jeanlescure. Using yarn workspaces, |
@jeanlescure When you import This is something I've wanted to implement for a little while now. It'll take some doing to get it right, but we can be smart about understanding the relationship between I believe when you turn off |
@cspotcode , as you put it, I'm going to correct you, the assumption is wrong and opposite to what we want 😅 In my case I do not want I think the piece of context missing here is that this is what the import looks like: import b from 'b'; There is no relative path, this is something that yarn/npm workspaces allows because in the node_modules directory a symbolic link is created. So what we are saying is, even though the import suggests that I then understand that, with |
@jeanlescure I see, I think our The expansion is actually done by
I can understand why your project does not want How to use scope on your project today
To test this today, I believe you can set env var If this works for you, please let me know and we can add it to Discussions as an official recipe. |
@cspotcode scope is exactly what I need. I've tested adding You've hit the nail in the head because I would actually need to have separate My vote is for un-deprecate ✋🏼 😄 |
Ok, excellent, I've created #1346 to add As far as setting the appropriate
Will that work for you? |
@cspotcode works great. Thanks 👍🏼 |
I tried the ts-node option with
|
This actually resolved my problem of running + "ts-node": {
+ "transpileOnly": true
+ }, |
I had a mixture of ts and js in a library and was hitting this issue. Since I'm using AWS amplify and importing my queries and mutations into my typescript project from a central library, I needed to change the sourcing from import { something } from '../../location', to const { something } = require('../../graphql/queries') |
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [ts-node](https://typestrong.org/ts-node) ([source](https://github.com/TypeStrong/ts-node)) | devDependencies | minor | [`10.4.0` -> `10.5.0`](https://renovatebot.com/diffs/npm/ts-node/10.4.0/10.5.0) | --- ### Release Notes <details> <summary>TypeStrong/ts-node</summary> ### [`v10.5.0`](https://github.com/TypeStrong/ts-node/releases/v10.5.0) [Compare Source](TypeStrong/ts-node@v10.4.0...v10.5.0) <!-- I don't make a discussion thread for every release. Github has a button to make a discussion thread for a release. Then I update the discussion thread to remove the release notes and instead link to the release. --> Questions about this release? Ask in the official discussion thread: [#​1634](TypeStrong/ts-node#1634) **Added** - Eliminate "Emit Skipped" errors ([#​693](TypeStrong/ts-node#693), [#​1345](TypeStrong/ts-node#1345), [#​1629](TypeStrong/ts-node#1629)) - Avoids all "Emit Skipped" errors by performing a fallback `transpileOnly`-style transformation. - Does not affect typechecking. Type errors are still detected and thrown. - Fallback has the same limitations as `isolatedModules`. This will only affect rare cases such as using `const enums` with `preserveConstEnums` disabled. - Fixes [#​693](TypeStrong/ts-node#693) - Graduate swc transpiler out of experimental; add `swc: true` convenience option ([docs](https://typestrong.org/ts-node/docs/transpilers)) ([#​1487](TypeStrong/ts-node#1487), [#​1536](TypeStrong/ts-node#1536), [#​1613](TypeStrong/ts-node#1613), [#​1627](TypeStrong/ts-node#1627)) - `"swc": true` or `--swc` will use swc for faster execution - This feature is no longer marked "experimental." Thank you to everyone who filed bugs! - swc transpiler attempts to load `@swc/core` or `@swc/wasm` dependencies from your project before falling-back to global installations ([#​1613](TypeStrong/ts-node#1613), [#​1627](TypeStrong/ts-node#1627)) - global fallback only occurs when using a global installation of ts-node - Add support for TypeScript's `traceResolution` output ([docs](https://www.typescriptlang.org/tsconfig/#traceResolution)) ([#​1128](TypeStrong/ts-node#1128), [#​1491](TypeStrong/ts-node#1491)) [@​TheUnlocked](https://github.com/TheUnlocked) - Support import assertions in ESM loader ([docs](https://nodejs.org/dist/latest-v17.x/docs/api/esm.html#import-assertions)) ([#​1557](TypeStrong/ts-node#1557), [#​1558](TypeStrong/ts-node#1558), [#​1559](TypeStrong/ts-node#1559), [#​1573](TypeStrong/ts-node#1573)) [@​Pokute](https://github.com/Pokute), [@​geigerzaehler](https://github.com/geigerzaehler) - Allows importing JSON files from ESM with the requisite flag ([docs](https://nodejs.org/dist/latest-v17.x/docs/api/esm.html#json-modules)) - `ts-node -vvv` also logs absolute paths to `ts-node` and `typescript`, to make it more obvious when you're accidentally using globally-installed versions ([#​1323](TypeStrong/ts-node#1323), [#​1620](TypeStrong/ts-node#1620)) - Add swc target "es2022" ([#​1535](TypeStrong/ts-node#1535), [#​1540](TypeStrong/ts-node#1540)) - When you have target es2022 in tsconfig, will use swc's es2022 target **Changed** - Initialize TypeScript compiler before starting REPL prompt ([#​1498](TypeStrong/ts-node#1498)) [@​TheUnlocked](https://github.com/TheUnlocked) - Improves responsiveness for first line of REPL input - Use `v8-compile-cache-lib` to load typescript - improves startup time ([#​1339](TypeStrong/ts-node#1339), [#​1603](TypeStrong/ts-node#1603)) - Support both `--camelCase` and `--hyphen-case` for all CLI flags; update documentation to use `--camelCase` ([#​1598](TypeStrong/ts-node#1598), [#​1599](TypeStrong/ts-node#1599)) - Not a breaking change; CLI continues to accept both forms - Make `TSError` `diagnosticText` property non-enumerable to prevent it from being logged below the stack ([#​1632](TypeStrong/ts-node#1632)) **Fixed** - Fix [#​1538](TypeStrong/ts-node#1538): REPL inputs fail to transpile via swc ([#​1538](TypeStrong/ts-node#1538), [#​1541](TypeStrong/ts-node#1541), [#​1602](TypeStrong/ts-node#1602)) - Fix [#​1478](TypeStrong/ts-node#1478): REPL erroneously logged `undefined` for all inputs after the first when using swc transpiler ([#​1478](TypeStrong/ts-node#1478), [#​1580](TypeStrong/ts-node#1580), [#​1602](TypeStrong/ts-node#1602)) - Fix [#​1389](TypeStrong/ts-node#1389): In `--showConfig` output, emit accurate `moduleTypes` paths resolved relative to the `tsconfig.json` which declared them ([#​1389](TypeStrong/ts-node#1389), [#​1619](TypeStrong/ts-node#1619)) - Fix: Remove indentation from `ts-node --help` output ([#​1597](TypeStrong/ts-node#1597), [#​1600](TypeStrong/ts-node#1600)) - Fix [#​1425](TypeStrong/ts-node#1425): Merged definitions correctly into `tsconfig.schemastore-schema.json` ([#​1425](TypeStrong/ts-node#1425), [#​1618](TypeStrong/ts-node#1618)) - Fix: Allow disabling `"use strict"` emit in SWC transpiler ([#​1531](TypeStrong/ts-node#1531), [#​1537](TypeStrong/ts-node#1537)) - Fix: Add missing `ERR_UNKNOWN_FILE_EXTENSION` constructor; was throwing `ERR_UNKNOWN_FILE_EXTENSION is not a constructor` ([#​1562](TypeStrong/ts-node#1562)) [@​bluelovers](https://github.com/bluelovers) - Fix [#​1565](TypeStrong/ts-node#1565): entrypoint resolution failed on node v12.0.x and v12.1.x ([#​1565](TypeStrong/ts-node#1565), [#​1566](TypeStrong/ts-node#1566)) [@​davidmurdoch](https://github.com/davidmurdoch) #### Docs - Explain `env -S` flag for shebangs ([docs](https://typestrong.org/ts-node/docs/usage#shebang)) ([#​1448](TypeStrong/ts-node#1448), [#​1545](TypeStrong/ts-node#1545)) [@​sheeit](https://github.com/sheeit), [@​chee](https://github.com/chee) - Suggest `skipIgnore` when you want to compile files in node_modules ([docs](https://typestrong.org/ts-node/docs/how-it-works)) ([#​1553](TypeStrong/ts-node#1553)) [@​webstrand](https://github.com/webstrand) - Fix typo in `moduleTypes` on options page ([docs](https://typestrong.org/ts-node/docs/options)) ([#​1630](TypeStrong/ts-node#1630), [#​1633](TypeStrong/ts-node#1633)) #### Misc - Adds experimental `experimentalResolverFeatures` option, but it does not do anything yet ([#​1514](TypeStrong/ts-node#1514), [#​1614](TypeStrong/ts-node#1614)) https://github.com/TypeStrong/ts-node/milestone/4 </details> --- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). Co-authored-by: cabr2-bot <[email protected]> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1156 Reviewed-by: crapStone <[email protected]> Co-authored-by: Calciumdibromid Bot <[email protected]> Co-committed-by: Calciumdibromid Bot <[email protected]>
Why did this work? |
It disables type checking, and emit skipped is an issue due to the type checker. It won’t compile files outside the typescript project when it’s type checking them. |
Note that modern versions of ts-node entirely avoid this emit skipped error. We detect when the typechecker skips emit, and we fallback to an alternative transpilation. The end result is that users of modern ts-node never see emit skipped even when typechecking. |
I have since fixed this "emit skipped" error, so recent versions of ts-node
should not have this issue. It comes from TypeScript in typechecking mode,
where TS may typecheck a file and yet refuse to emit JS for it. I now
detect when this happens and use an alternative method to emit to JS. The
result is: typechecking still works, and this error goes away.
And of course, nothing changes for transpileOnly mode: the error never
existed in that mode. So everything still works.
…On Tue, Jun 21, 2022, 4:27 AM Daniel ***@***.***> wrote:
This actually resolved my problem of running ts-node 10.1.0
+ "ts-node": {+ "transpileOnly": true+ },
Why did this work?
—
Reply to this email directly, view it on GitHub
<#693 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC35OAFUIRW6OPJVDAEX73VQF4INANCNFSM4FWZAQHA>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
Im trying to import a file outside of the project. It's a shared file between the frontend and the server.
When i try import it it throws this error:
I'm able to import it from my angular project which is a sibling.
I've tried adding the file to my tsconfig under includes and files. This is what my tsconfig looks like:
And this is my tsconfig file that the project extends:
The text was updated successfully, but these errors were encountered: