tinacms icon indicating copy to clipboard operation
tinacms copied to clipboard

Generated client.ts import of ./types missing file extension

Open Daniel15 opened this issue 2 months ago • 0 comments

Describe the issue that you're seeing. Any videos (eg. YouTube or Loom) or screenshots help!

If I try to import the tina/__generated__/client.ts file in a Node.js script (e.g. to run an express server for the datalayer), I get an error like this:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/daniel/src/tina-selfhost-test1/tina/__generated__/types' imported from /home/daniel/src/tina-selfhost-test1/tina/__generated__/client.ts

According to the Node.js documentation, file extensions must be provided when using ES modules, so this import should actually have a .ts extension, like this:

import { queries } from "./types.ts";

not:

import { queries } from "./types";

Workaround: Run it using tsx (npx tsx src/server/server.ts) which handles this fine.

Reproduction

N/A

Steps to reproduce

Create new TinaCMS site (I used the Astro template) Create new server.ts file:

import {client} from "../../tina/__generated__/client.ts";

Run it:

node server.ts

System Info

System:
    OS: Linux 6.15 Fedora Linux 42 (KDE Plasma Desktop Edition)
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
    Memory: 16.04 GB / 31.24 GB
    Container: Yes
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.21.0 - /home/daniel/.volta/tools/image/node/22.21.0/bin/node
    Yarn: 4.10.3 - /home/daniel/.volta/tools/image/yarn/4.10.3/bin/yarn
    npm: 10.9.4 - /home/daniel/.volta/tools/image/node/22.21.0/bin/npm
  Browsers:
    Firefox: 141.0
    Firefox Developer Edition: 141.0
  npmPackages:
    @tinacms/cli: ^1.11.0 => 1.11.0 
    @tinacms/datalayer: ^1.4.1 => 1.4.1 
    tinacms: ^2.9.0 => 2.9.0

Validations

Daniel15 avatar Oct 27 '25 00:10 Daniel15