#Nest start/build Error: Cannot find module '/home/.../dist/main' #12557

17 messages · Page 1 of 1 (latest)

finite scarab
visual mural
#

Hello, yes, same person you've been talking to there 🙂 Glad you finally came to the server to chat

#

Are you running the nest command from the global install, or through your package manager install? e.g. nest start vs yarn nest start

finite scarab
#

As I mentioned in Issue, I runned node_modules/.bin/nest start --builder tsc

#

For some reason with global one, it could not find source map (don't really remember exact name) register. UPD: Oh, it's maybe related to my actual project not this repro.

visual mural
#

I just realized there was a step I missed in the reproduction steps (sorry about that) and I'll update the ssue with what I just found.

#

The "problem" here isn't with Nest, but with how tsc works when in incremental mode and having a .tsbuildinfo file

#

Because that file exists, and there's been no changes, Typescript reads it and goes "Oh, the dist/main already should exist and there's nothing to do. Regardless of the fact that you manually deleted the file

#

So if you delete the .tsbuildinfo as well as the dist/main and then run nest start again, it all works

finite scarab
#

oh so I have to rm .tsbuildinfo beforehand?

visual mural
#

Yep. That's an info file for Typescript to figure out what needs to be re-compiled vs what should stay as is

#

Or just don't use incremenetal, as I believe there are quirks with it and the @nestjs/cli. I'll need to go look through those issues again

finite scarab
#

Yes, this was the issue. Now it makes clear. Thank you!
But It's actually hard to notice/debug, when your thoughts are not on the right way. I'd be glad to see some warning at least, in cli tool)

visual mural
#

I'll think about what can be done. The @nestjs/cli is mainly just a thin wrapper around the tsc CLI (or webpack if that's the bundler/transpiler you're using) so this is really functionality of the tsc CLI we'd have to be warning about

finite scarab
#

cli loads the tsconfig.json, right? so it could check for tsBuildInfoFile field, and when spawning node fails, notify the user/developer

visual mural
#

Do you want to add that functionality into the CLI?

#

PRs are more than welcome