Nested `node_modules` generated under `esm`/`script` which breaks module resolution
- Dominant language
- Rust
- Stars
- 1.3k
- Forks
- 49
- PR merge metrics
- No merged PRs in 30d
Description
## Issue
`dnt` is outputting dependencies under `npm/esm/node_modules` and `npm/script/node_modules` in addition to the root `npm/node_modules`. The nested `node_modules` only contain an incomplete set of files from the [ya-svg-transform](https://www.npmjs.com/package/ya-svg-transform) package which is installed correctly in the root `node_modules` folder.
This results in the tests failing with the following error:

## Temporary Workaround
I found that deleting the extra `node_modules` directories resolved the issue so I added the following to my `postBuild` hook:
`build_npm.ts`
```
...
await build({
postBuild() {
...
// Delete unwanted node_modules outputs
// Deno.removeSync("npm/esm/node_modules", { recursive: true });
// Deno.removeSync("npm/script/node_modules", { recursive: true });
},
});
```
## Notes
Not sure why these extra files are being emitted but it seems to me it may be an issue with the [ts-morph](https://github.com/dsherret/ts-morph) package.
Contributor guide
Assessment
This issue has not been assessed yet.