Chris Tsongas
10/15/2021, 6:17 AMheroku run npx prisma migrate deploy
however when I try to seed the database using heroku run npx prisma db seed
it borks with the following error:
Running seed command `ts-node prisma/seed/index.ts` ...
An error occured while running the seed command:
Error: Command failed with ENOENT: ts-node prisma/seed/index.ts
spawn ts-node ENOENT
Ryan
10/15/2021, 6:20 AMChris Tsongas
10/15/2021, 6:34 AMChriss-MBP:api chris$ npx prisma db seed
Environment variables loaded from .env
Running seed command `ts-node prisma/seed/index.ts` ...
Seeding employee model...
Seeding eventPosition model...
Seeding language model...
Chris Tsongas
10/15/2021, 6:34 AMRyan
10/15/2021, 6:37 AMChris Tsongas
10/15/2021, 6:39 AMChris Tsongas
10/15/2021, 6:43 AMts-node
command?Ryan
10/15/2021, 6:45 AMnpx ts-node prisma/seed/index.ts
work instead of running prisma db seed
?Chris Tsongas
10/15/2021, 6:53 AMts-node
however for seeding users my seed file imports a helper function to hash passwords with bcrypt, and it appears TS can't find the dev dependencies for the types:
Running npx ts-node prisma/seed/index.ts on ⬢ afscme-local-328-api-staging... up, run.3850 (Hobby)
npm WARN exec The following package was not found and will be installed: ts-node
/app/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:744
return new TSError(diagnosticText, diagnosticCodes);
^
TSError: ⨯ Unable to compile TypeScript:
src/utils/helpers.ts:3:20 - error TS7016: Could not find a declaration file for module 'bcrypt'. '/app/node_modules/bcrypt/bcrypt.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/bcrypt` if it exists or add a new declaration (.d.ts) file containing `declare module 'bcrypt';`
3 import bcrypt from 'bcrypt'
~~~~~~~~
src/utils/helpers.ts:4:30 - error TS7016: Could not find a declaration file for module 'jsonwebtoken'. '/app/node_modules/jsonwebtoken/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/jsonwebtoken` if it exists or add a new declaration (.d.ts) file containing `declare module 'jsonwebtoken';`
4 import { sign, verify } from 'jsonwebtoken'
~~~~~~~~~~~~~~
at createTSError (/app/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:744:12)
at reportTSError (/app/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:748:19)
at getOutput (/app/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:935:36)
at Object.compile (/app/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1237:30)
at Module.m._compile (/app/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1364:30)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Object.require.extensions.<computed> [as .ts] (/app/.npm/_npx/1bf7c3c15bf47d04/node_modules/ts-node/src/index.ts:1368:12)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
diagnosticText: "\x1B[96msrc/utils/helpers.ts\x1B[0m:\x1B[93m3\x1B[0m:\x1B[93m20\x1B[0m - \x1B[91merror\x1B[0m\x1B[90m TS7016: \x1B[0mCould not find a declaration file for module 'bcrypt'. '/app/node_modules/bcrypt/bcrypt.js' implicitly has an 'any' type.\n" +
" Try `npm i --save-dev @types/bcrypt` if it exists or add a new declaration (.d.ts) file containing `declare module 'bcrypt';`\n" +
'\n' +
"\x1B[7m3\x1B[0m import bcrypt from 'bcrypt'\n" +
'\x1B[7m \x1B[0m \x1B[91m ~~~~~~~~\x1B[0m\n' +
"\x1B[96msrc/utils/helpers.ts\x1B[0m:\x1B[93m4\x1B[0m:\x1B[93m30\x1B[0m - \x1B[91merror\x1B[0m\x1B[90m TS7016: \x1B[0mCould not find a declaration file for module 'jsonwebtoken'. '/app/node_modules/jsonwebtoken/index.js' implicitly has an 'any' type.\n" +
" Try `npm i --save-dev @types/jsonwebtoken` if it exists or add a new declaration (.d.ts) file containing `declare module 'jsonwebtoken';`\n" +
'\n' +
"\x1B[7m4\x1B[0m import { sign, verify } from 'jsonwebtoken'\n" +
'\x1B[7m \x1B[0m \x1B[91m ~~~~~~~~~~~~~~\x1B[0m\n',
diagnosticCodes: [ 7016, 7016 ]
}
Chris Tsongas
10/15/2021, 6:55 AM.d.ts
but I haven't done that before....Chris Tsongas
10/15/2021, 6:56 AMRyan
10/15/2021, 7:01 AMts-node
is probably not catching them.Chris Tsongas
10/15/2021, 7:05 AMsrc/utils/helpers.ts
I'd add a src/utils/helpers.d.ts
file?Ryan
10/15/2021, 7:24 AMnode_modules
. What’s your tsconfig.json
look like?Chris Tsongas
10/15/2021, 7:27 AM{
"compilerOptions": {
"sourceMap": true,
"outDir": "dist",
"strict": true,
"lib": [
"esnext"
],
"esModuleInterop": true
}
}
Chris Tsongas
10/15/2021, 7:27 AMChris Tsongas
10/15/2021, 8:01 AMChris V
10/15/2021, 8:31 AMdevDependencies
aren't installed - I checked the contents of node_modules
on the dyno and they're not there.
Seems consistent with what Heroku docs say as well: We’ve updated the default behavior to install all dependencies listed in package.json
during build, and to strip out the developer dependencies before the app is deployed.
I'll trying preventing the pruning of devDependencies
Chris V
10/15/2021, 8:54 AMYARN_PRODUCTION=false
and NPM_CONFIG_PRODUCTION=false
did the trick. It prevents the dev dependencies from being pruned, making them available even after the build processLars Ivar Igesund
10/15/2021, 9:19 AM