-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
Typescript/SWC not working when root directory name contains node_modules #74404
Comments
🤔 could you show a video of the issue happening? https://stackblitz.com/github/Netail/repro-next-typescript-node_modules?file=README.md it works fine here, at least for me. |
I assume stackblitz loads the content of a repo differently in, so the directory where the project gets downloaded in is not the same as the repository name. Or node_modules are not allowed to search outside of the directory, idk repro-next-typescript-node_modules.-.Visual.Studio.Code.2024-12-29.22-49-11.mp4 |
It's not about the node_modules directory inside of the root directory. It's about the root directory name itself, which then contains the app, node_modules etc
Happens on both macos & windows 10 |
Oh no, uff, so the issue is Alright, that's not good... let me do some quick research |
Yes 😅, I see the confusion there. I first had something regarding the name in the title |
I mean it's quite an edge case, who would add node_modules in the name of their root directory in a real project? I only stumbled upon it because I was working on a different repro. |
Ok, I think I've got the error narrowed down, let me try to see if I can make a PR. |
Awesome, thanks :) |
Link to the code that reproduces this issue
https://github.com/Netail/repro-next-typescript-node_modules
To Reproduce
node_modules
(In this case the default git clone namerepro-next-typescript-node_modules
)yarn install
yarn dev
localhost:3000
so it compiles the pageimport type
or: FC
)Current vs. Expected behavior
When the root directory contains the word
node_modules
, SWC fails to transpile the typescript files, while the rest seems to be working fine. I expected Typescript to be working fine, regardless of the root directory nameProvide environment information
Which area(s) are affected? (Select all that apply)
TypeScript, SWC
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local)
Additional context
I was testing another bug regarding node_modules & bundling and called the directory something with node_modules, this resulted in some "Module parse failed: Unexpected token" errors, which took me a few hours to realise it was because of the root directory name
The text was updated successfully, but these errors were encountered: