gemini-server
gemini-server copied to clipboard
TypeError: gemini is not a function
I'm getting this error no matter what I do:
TypeError: gemini is not a function
I may be doing something wrong. This is the entire code I'm testing:
import { readFileSync } from 'fs';
import gemini from 'gemini-server';
const options = {
cert: readFileSync('cert.pem'),
key: readFileSync('key.pem'),
}
const app = gemini(options);
app.on('/', gemini.serveStatic('index.gmi'));
index.gmi
is there and certificate is also there (I logged options
and it comes out fine, both cert.pem
and key.pem
).
I also tried using require
instead of import
, same thing happened.
I'm running node server.js
.
I installed with npm install --save gemini-server
.
I'm sure I'm doing something wrong, I can't figure out what.
also, I'm on Node v18.7.0
Ah I see. It's likely an issue with how I'm building the non-typescript version from typescript. I'll look in to it.
@jgkaplan Right! I now tested it using ts-node
and it works fine! I'm not used to Typescript but is a good time as any to learn :)
As a workaround. replace
const gemini = require('gemini-server');
with
const gemini = require('gemini-server').default;
worked for me
import { GeminiServer } from "gemini-server";
works in 2024.