You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there, I am trying to get Fastify to work with internal packages to make the codebase cleaner and reusable across different frontends using ofcourse turborepo. However, while setting this up, I’m encountering several issues when importing internal packages into Fastify. Therefore, I’m looking for some advice on how to best structure this project.
Currently, I have a Fastify backend with the following package.json:
Everything seems to build correctly, and installation also works fine. However, when running the server in either dev or prod mode, I get the following errors:
dev:
Debugger listening on ws://127.0.0.1:9230/08e328f1-656a-4ea9-be12-92513319d120
For help, see: https://nodejs.org/en/docs/inspector
import { isInBoundingBox } from "@board-builder/board-logic/logic/geography/geography";
^
SyntaxError: The requested module '@board-builder/board-logic/logic/geography/geography' does not provide an export named 'isInBoundingBox'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:182:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:266:5)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:644:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)
Node.js v22.16.0
prod:
> node ./dist/index.js
node:internal/modules/esm/get_format:219
throw new ERR_UNKNOWN_FILE_EXTENSION(ext, filepath);
^
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for ~/board-builder/packages/board-logic/src/logic/geography/AreaPlacementFinder.ts
at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:219:9)
at defaultGetFormat (node:internal/modules/esm/get_format:245:36)
at defaultLoad (node:internal/modules/esm/load:120:22)
at async ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:580:32) {
code: 'ERR_UNKNOWN_FILE_EXTENSION'
}
Node.js v22.16.0
It seems this issue might be related to the configuration of my internal package or the backend setup. E.g. in the transformation of ts files to js files which is with the current setup not supported.
For reference, here’s the configuration for the internal package’s package.json and tsconfig.json:
My frontend will be using Nuxt, and based on initial tests, the setup seems to work fine there.
Could you please advise on what configuration settings I should look into to make this work properly? I’ve tried several approaches and reviewed both Fastify and Turborepo boilerplates, but I haven’t managed to get it running yet.
I suspect the issue might be related to the exports field in my package.json or the need for an index file. However, I’d like to know what the best approach would be - ideally with the least amount of configuration changes.
Also, in case there are other Node servers that work better with Turborepo (with clear instructions and similar performance), I’d be open to considering those as well.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Hi there, I am trying to get Fastify to work with internal packages to make the codebase cleaner and reusable across different frontends using ofcourse turborepo. However, while setting this up, I’m encountering several issues when importing internal packages into Fastify. Therefore, I’m looking for some advice on how to best structure this project.
Currently, I have a Fastify backend with the following package.json:
and the tsconfig.json as follows:
Everything seems to build correctly, and installation also works fine. However, when running the server in either dev or prod mode, I get the following errors:
dev:
prod:
It seems this issue might be related to the configuration of my internal package or the backend setup. E.g. in the transformation of ts files to js files which is with the current setup not supported.
For reference, here’s the configuration for the internal package’s package.json and tsconfig.json:
My frontend will be using Nuxt, and based on initial tests, the setup seems to work fine there.
Could you please advise on what configuration settings I should look into to make this work properly? I’ve tried several approaches and reviewed both Fastify and Turborepo boilerplates, but I haven’t managed to get it running yet.
I suspect the issue might be related to the exports field in my package.json or the need for an index file. However, I’d like to know what the best approach would be - ideally with the least amount of configuration changes.
Also, in case there are other Node servers that work better with Turborepo (with clear instructions and similar performance), I’d be open to considering those as well.
Thanks!
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions