typst.ts: Can't import Typst.ts module in Node.js

Describe the bug I try to import the typst.ts module using the following code :

import { createTypstRenderer } from '@myriaddreamin/typst.ts';
const renderer = createTypstRenderer();

renderer.init();

And I got the following error :

node:internal/modules/cjs/loader:1042
  throw err;
  ^

Error: Cannot find module '@myriaddreamin/typst-ts-renderer'
Require stack:
- /home/millian/test/node_modules/@myriaddreamin/typst.ts/dist/cjs/renderer.js
- /home/millian/test/node_modules/@myriaddreamin/typst.ts/dist/cjs/index.js
- /home/millian/test/main.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
    at Module._load (node:internal/modules/cjs/loader:885:27)
    at Module.require (node:internal/modules/cjs/loader:1105:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/home/millian/test/node_modules/@myriaddreamin/typst.ts/dist/cjs/renderer.js:5:29)
    at Module._compile (node:internal/modules/cjs/loader:1218:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)
    at Module._load (node:internal/modules/cjs/loader:922:12)
    at Module.require (node:internal/modules/cjs/loader:1105:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/millian/test/node_modules/@myriaddreamin/typst.ts/dist/cjs/renderer.js',
    '/home/millian/test/node_modules/@myriaddreamin/typst.ts/dist/cjs/index.js',
    '/home/millian/test/main.js'
  ]
}

Node.js v18.13.0

Expected behavior Import and use the module correctly.

Desktop :

  • OS: Ubuntu 23.04
  • Node.js v18.13.0

Additional context I’m completely new in TypeScript development. There are many things I don’t understand and master. Mainly I would like to import the module in Node.js and use it with electron or in my browser directly ? How I suppose to do that ? Thanks in advance. Have a nice day.

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Reactions: 1
  • Comments: 19 (10 by maintainers)

Most upvoted comments

No problem @Myriad-Dreamin, I will stay tune. Thanks you for all of your work. Without you and your lib my basic Idea to make a typstDrawingTool would have been much more difficult. For now I can import the lib in Node.JS so we can close the issue. For the solution, download the provided node.js template. Thank you again 😁