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
node_modules are not ignored when providing a project path that is in node_modules. #1477
Comments
You can commit a At first glance, I thought this was the same as #1341 but I'm not sure. |
You're using an older version of ts-node; is that intentional? |
oops, fixed the version of ts-node, thanks for noticing that @cspotcode. |
No problem, let me know when you have a reproduction and I'll take a look. |
Hi @cspotcode - I got a reproduction working! https://stackblitz.com/edit/ts-node-project-in-node-modules?file=index.js |
@dylang The warning appears to be an unrelated bug, so it's great that you've reported it, but I wonder if it's related to your node_modules problem or not. I've created a separate issue to track the warning bug: #1488 For your node_modules issue, I'm curious, have you used these tsconfig.json files with
I'm not sure if tsconfig files are meant to be used this way. I realize you're using ts-node, not tsc, but we still have to match tsc config behavior pretty closely. I'll have to double-check the code, but this behavior may be intentional. That is to say, your chosen tsconfig determines the "root directory" of your project and we set other options like That's all the time I have for today but I can come back to this soon. |
I updated your reproduction with a workaround for #1488 and some I see our docs say |
I think I found a clean workaround to my problem: require('ts-node').register({
pretty: true,
transpileOnly: true,
// Use allowJs so that we can run js files that have esm-style import/export.
compilerOptions: { allowJs: true, rootDir: getRepoPath() },
// By not providing a tsconfig.json, ts-node will use the best choice for the version of node in use.
// And we can still provide our own using TS_NODE_PROJECT=<path to tsconfig.json>.
skipProject: !process.env.TS_NODE_PROJECT
}); I didn't realize we had the ability to override
|
Closing. To summarize: We established that pointing Also, it conflicts with intended npx support in ts-node. If your tsconfig is within a node_modules directory, then we reason that your project is within node_modules and that we should transform files there. We fixed the |
Search Terms
node_modules
baseDir
ignoreBaseDir
Accessing non-existent property 'getOptionValue' of module exports inside circular dependency
Expected Behavior
tsconfig.json
thatts-node
uses, and not worry about conflicts with thetsconfig.json
that the projects use that use my code.node_modules
.Actual Behavior
node_modules
is compiled.ts-node
withts-node
:It appears to be caused by prioritizing the
configFileDirname
over thecwd
or any provided directory via configuration:https://github.com/TypeStrong/ts-node/blob/master/src/index.ts#L629-L643
createIgnore
usespath.Relative
, so all paths innode_modules
end relative to another directory innode_modules
as../../module
and do not contain the stringnode_modules
so they are not ignored.https://github.com/TypeStrong/ts-node/blob/master/src/index.ts#L1332-L1338
Steps to reproduce the problem
./tsconfig.ts-node.json
:Minimal reproduction
I understand why a reproduction is necessary but I'm not sure best way to do it as it requires the code to be in
node_modules
and I prefer avoiding publishing a new module for this issue.Maybe there's an online REPL that supports file:// for module versions to install local modules?
Specifications
The text was updated successfully, but these errors were encountered: