Karthik S Kumar
08/17/2021, 9:57 AMthdxr
08/17/2021, 11:47 AMthdxr
08/17/2021, 11:47 AMthdxr
08/17/2021, 11:47 AMKarthik S Kumar
08/17/2021, 11:50 AMthdxr
08/17/2021, 11:51 AMKarthik S Kumar
08/17/2021, 12:35 PMKarthik S Kumar
08/17/2021, 12:37 PM/trip/app
we will get a 500 error and in the logs we can see that logger is missingthdxr
08/17/2021, 12:38 PMthdxr
08/17/2021, 12:38 PMthdxr
08/17/2021, 12:38 PMKarthik S Kumar
08/17/2021, 12:52 PMthdxr
08/17/2021, 12:57 PMthdxr
08/17/2021, 12:57 PMKarthik S Kumar
08/17/2021, 12:57 PMthdxr
08/17/2021, 12:58 PMthdxr
08/17/2021, 12:58 PM"main": "dist/index.js"
thdxr
08/17/2021, 12:59 PMtsconfig.json
looks like this
{
"extends": "@tsconfig/node14",
"include": [
"index.ts"
],
"compilerOptions": {
"declaration": true,
"outDir": "dist"
}
}
thdxr
08/17/2021, 12:59 PMdist/
and then when another package imports, it looks for dist/index.js
Karthik S Kumar
08/17/2021, 1:05 PMKarthik S Kumar
08/17/2021, 1:05 PMKarthik S Kumar
08/17/2021, 1:05 PMdist/index.js
in package.jsonthdxr
08/17/2021, 1:20 PMKarthik S Kumar
08/18/2021, 5:00 AMsst start
or sst deploy
?thdxr
08/18/2021, 5:07 AMthdxr
08/18/2021, 5:08 AMthdxr
08/18/2021, 5:08 AMKarthik S Kumar
08/18/2021, 5:16 AMgio
09/20/2021, 11:43 PMWaiting for the debugger to disconnect...
7b27afef-1906-48c9-81a8-c92c15644c03 ERROR Error: Cannot find module '@linkey/types'
Require stack:
- /Users/GioMaligno/Workspace/linkey/backend/.build/services/stations/index.js
From your example I added a workspace for types (to share type between backend and frontend) as described in the root package.json
"workspaces": ["backend", "types"]
Types tsconfig:
{
"extends": "../tsconfig.json",
"include": ["index.ts"],
"compilerOptions": {
"declaration": true,
"outDir": "dist",
"experimentalDecorators": true,
"baseUrl": ".",
"paths": {
"@linkey/types": ["index.ts"],
},
"strictPropertyInitialization": false
}
}
Types package.json:
{
"name": "@linkey/types",
"version": "0.1.4",
"scripts": {
"build": "sst build",
"script": "esr",
"test": "jest"
},
"dependencies": {
"class-validator": "^0.13.1"
},
"devDependencies": {
"esbuild-runner": "^2.2.1",
"jest": "^27.2.0"
}
}
Backend tsconfig:
{
"extends": "../tsconfig.json",
"include": ["core", "services", "test", "scripts"],
"compilerOptions": {
"declaration": true,
"outDir": "dist",
"experimentalDecorators": true,
"baseUrl": ".",
"paths": {
"@linkey/core": ["core"],
},
"strictPropertyInitialization": false
}
}
Backend package.json :
{
"name": "@linkey/backend",
"version": "0.0.1",
"scripts": {
"build": "sst build",
"script": "esr",
"test": "jest"
},
"dependencies": {
"@linkey/types": "0.1.4",
"@types/aws-lambda": "^8.10.83",
"class-transformer": "^0.4.0"
},
"devDependencies": {
"@types/aws4": "^1.5.2",
"@types/supertest": "^2.0.11",
"aws4": "^1.11.0",
"esbuild-runner": "^2.2.1",
"jest": "^27.2.0",
"supertest": "^6.1.6"
}
}
In my node_module folder @linkey/backend was built on “.build” folder instead of @linkey/types which is never build (no .build folder).
It is the first time I use Yarn Workspace I suppose to make some huge mistake 🤔thdxr
09/20/2021, 11:45 PMthdxr
09/20/2021, 11:46 PMgio
09/21/2021, 12:02 AMthdxr
09/21/2021, 12:06 AMpackage.json
means extra complexitythdxr
09/21/2021, 12:06 AM../
thdxr
09/21/2021, 12:07 AMthdxr
09/21/2021, 12:07 AMgio
09/21/2021, 12:10 AMgio
09/21/2021, 12:11 AMthdxr
09/21/2021, 12:20 AM