Reputation: 31237
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:
> [email protected] 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,
heroku update
d the CLIStill, the error scenario remains unchanged!
Any ideas why is my deployment crashing?
Upvotes: 2
Views: 443
Reputation: 102
npm install --save tslib
got me past this problem.
For me, I had to explicitly add tslib
as a runtime dependency. Even though tslib was available locally, it seems the heroku cli does a tree shaking process where it removes node modules that it doesn't think are necessary.
Upvotes: 5