-
-
Notifications
You must be signed in to change notification settings - Fork 540
can't run in existing project with node_modules #28
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
Comments
If you have a case where this can be reproduced, I'd appreciate some more details. It sounds like you're running into a TypeScript issue though, and you're using modules that have duplicate type definition references. |
It seems to be related to my tsconfig.json. I was able to recreate it in a separate empty repository by having a local [email protected] and [email protected] and a tsconfig.json with the following:
this causes any form of ts-node that runs to error out with hundreds of duplicate identifier errors. Is that compiler option incompatible with ts-node? |
@snapwich Have you tried using it with |
this is the contents of the new project
so is it globbing through my node_modules then? |
Yes, that's the default behavior of TypeScript too. This describes your issue: microsoft/TypeScript#3289. |
that looks like the problem. thanks for your help |
@blakeembrey reading further into this, it looks like this still may be a ts-node problem as far as pulling in files. on https://github.com/Microsoft/typescript/wiki/tsconfig.json it says "When input files are specified on the command line, tsconfig.json files are ignored." which does seem to be the case with tsc. With the given tsconfig.json above: |
That's documentation for |
I could add a Edit: Also, those are conditions in which |
I use I'm not sure the standard convention for most typescript projects, but a root entry point with typescript references is what was recommended with the webpack typescript loader I am using, which is also why I have a tsconfig.json file in the root folder with no files currently. |
Yes, you can use that. I recommend against references in personal TypeScript projects and would advocate for using |
Unfortunately I can't use tsconfig.json "files" for my webpack typescript loader files, but it would be nice if I could share my tsconfig.json across my client and server-side code. Is there any harm that would come from having ts-node emulate tsc's behavior of ignoring the tsconfig.json "files" when the entry files are present on the command line? |
@snapwich Why not? What Edit: Do correct me if I'm wrong though, but I believe those are just "modes" that kick it from |
@blakeembrey you're right. it looks like |
For some reason command line ts-node seems to search the local node_modules folder even when there are no references to it in the file you run. Also, if I run ts-node to get a REPL and execute any command inside a project that has typescript in it, but also have typescript installed globally, I get thousands of duplicate identifier errors.
If I remove typescript from the local project, I get
node_modules/autoprefixer-loader/node_modules/postcss/postcss.d.ts (2,22): Cannot find module 'd.ts/postcss'. (2307) node_modules/autoprefixer-loader/node_modules/postcss/postcss.d.ts (3,2): Duplicate identifier 'default'. (2300)
so it appears to search my node_modules folder for all kinds of definitions and then throw a bunch of errors before it evaluates the first line of typescript. I get the same errors running an empty typescript file. Is this expected behavior?
The text was updated successfully, but these errors were encountered: