ts-node-dev runs into an error: "Cannot find module 'typescript'"

I had this problem myself and even tough I didn't clearly understand the main cause, I did the following stuff and it worked out.

So basically I have installed the ts-node-dev package as a dev dependency(npm i --save-dev ts-node-dev), and after that was running into another error regarding rxjs, so I just installed that too as a dependency(npm i rxjs) and after that it worked ts-node-dev as well as npx ts-node-dev