Skip to content Skip to sidebar Skip to footer

Typescript Cannot Find Module './lib'

I am trying to use winston-aws-cloudwatch library in my server side app in Typescript. I have a SSCCE setup on GitHub in case you want to reproduce the issue. Here is the detail. i

Solution 1:

Ah! So, after much trial and error it turned out the main culprit was:

"allowJs":true,

For some reason it was copying some parts of node_modules to ./dist one of those files was as you can see in the error:

dist/node_modules/winston-aws-cloudwatch/index.js

Now the problem was two fold

  1. I did not know whether node_modules should be copied to dist. I thought all of it should go. Which is WRONG.

    None of node_modules should go in dist, the compiled files shall refer paths to figure out the location of node_modules.

  2. The second problem was I could not see error go away when, in the fit of agony, I was switching on and off all the tsconfig options and rerunning the build. The reason was, dist DOES NOT CLEAR OFF. I figured this by an obscure luck while repeating the same process umpteenth time!

Anyway, good learning. Hope some of it would help someone someday.

Post a Comment for "Typescript Cannot Find Module './lib'"