gemini-server icon indicating copy to clipboard operation
gemini-server copied to clipboard

TypeError: gemini is not a function

Open pedrogpimenta opened this issue 2 years ago • 4 comments

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.

pedrogpimenta avatar Aug 17 '22 07:08 pedrogpimenta

also, I'm on Node v18.7.0

pedrogpimenta avatar Aug 17 '22 07:08 pedrogpimenta

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 avatar Aug 17 '22 15:08 jgkaplan

@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 :)

pedrogpimenta avatar Aug 19 '22 11:08 pedrogpimenta

As a workaround. replace

const gemini = require('gemini-server');

with

const gemini = require('gemini-server').default;

worked for me

ShortRoundDev avatar Oct 28 '22 13:10 ShortRoundDev

import { GeminiServer } from "gemini-server";

works in 2024.

darrylcousins avatar Feb 28 '24 03:02 darrylcousins