I have a typescript express project which I need to deploy to Heroku.
This project is working absolutely fine on the local machine however when deploying the same to Heroku it throws this strange error:
> learning@0.0.0 start /app
> node -r module-alias/register ./dist --env=production
internal/modules/cjs/loader.js:969
throw err;
^
Error: Cannot find module 'tslib'
Require stack:
- /app/dist/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
at Function.Module._resolveFilename (/app/node_modules/module-alias/index.js:49:29)
at Function.Module._load (internal/modules/cjs/loader.js:842:27)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/app/dist/index.js:3:17)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/app/dist/index.js' ]
to my surprise - tslib does not exist in the entire application code!!!
This means it should not be a required module as the node should take care of the execution.
As per the recommendations on the web,
- As per this thread, I have
heroku updated the CLI - This thread says that it's a CLI problem but when I deploy from Heroku web portal then too I'm getting the error
- As per this thread, I have cleaned the Heroku directory
Still, the error scenario remains unchanged!
Any ideas why is my deployment crashing?