I tried to push to heroku a close-to-clean project with mongoose and got runtime errors right off the bat.
It's the same repo I shared with you before, with minor changes that shouldn't have made a difference as far as this issue is concerned:
https://github.com/royibernthal/tsedrepro
node dist/index.js doesn't throw any errors when testing locally (after building of course).
Here's the error log:
> [email protected] start /app
> node dist/index.js
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'change-case'
Require stack:
- /app/node_modules/@tsed/mongoose/lib/utils/createSchema.js
- /app/node_modules/@tsed/mongoose/lib/utils/index.js
- /app/node_modules/@tsed/mongoose/lib/index.js
- /app/dist/Server.js
- /app/dist/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/app/node_modules/@tsed/mongoose/lib/utils/createSchema.js:8:23)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/app/node_modules/@tsed/mongoose/lib/utils/index.js:4:22)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/app/node_modules/@tsed/mongoose/lib/index.js:8:22)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/app/node_modules/@tsed/mongoose/lib/utils/createSchema.js',
'/app/node_modules/@tsed/mongoose/lib/utils/index.js',
'/app/node_modules/@tsed/mongoose/lib/index.js',
'/app/dist/Server.js',
'/app/dist/index.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node dist/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /app/.npm/_logs/2021-03-18T20_34_47_193Z-debug.log
Process exited with status 1
State changed from starting to crashed
Hello @royibernthal
You're not the first to ask me about this issue. I don't know why it occurs because change-case is dependencies of @tsed/schema and this package is a dependencies of your project. Npm should install this dependencies as expected but for an obscure reason the package isn't installed on heroku.
The caveat is to install the change-case as your dependencies on your project until I haven't a proper solution.
I'll try to investigate on it :)
See you
Romain
Hey Romain,
I agree it sounds like a weird issue, though it seems you quickly resolved it. Thanks yet again :)
Royi
It's interesting. In the package-lock.json, npm consider the package as devDep:
"change-case": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/change-case/-/change-case-4.1.2.tgz",
"integrity": "sha512-bSxY2ws9OtviILG1EiY5K7NNxkqg/JnRnFxLtKQ96JaviiIxi7djMrSd0ECT9AC+lttClmYwKw53BWpOMblo7A==",
"dev": true, ////
To reproduce the bug locally run npm ci.
Solved with 6.34.3