elysiajs / elysia-jwt

Plugin for Elysia for using JWT Authentication
MIT License
38 stars 16 forks source link

jwt.default is not a function #35

Closed nodirbekrajaboff closed 3 months ago

nodirbekrajaboff commented 3 months ago

JWT not working after build: ubuntu@ip-172-31-20-32:~/########/server$ pm2 logs 1 [TAILING] Tailing last 15 lines for [1] process (change the value with --lines option) /home/ubuntu/.pm2/logs/######-server-out.log last 15 lines: /home/ubuntu/.pm2/logs/######-server-error.log last 15 lines: 1|####### | Bun v1.1.8 (Linux x64) 1|####### | 102549 | 1|####### | 102550 | // src/plugins/jwt.ts 1|####### | 102551 | var jwt = __toESM(require_cjs6(), 1); 1|####### | 102552 | if (!process.env.SECRET_KEY) 1|####### | 102553 | throw new Error("SECRET not found"); 1|####### | 102554 | var jwtPlugin = new Elysia().use(jwt.default({ 1|####### | ^ 1|####### | TypeError: jwt.default is not a function. (In 'jwt.default({ 1|####### | name: "jwt", 1|####### | secret: process.env.SECRET_KEY 1|####### | })', 'jwt.default' is an instance of Object) 1|####### | at /home/ubuntu/######/server/build/index.js:102554:34 1|####### | 1|####### | Bun v1.1.8 (Linux x64)

My codes

import jwt from "@elysiajs/jwt";
import { Elysia } from "elysia";

if (!process.env.SECRET_KEY) throw new Error("SECRET not found");

const jwtPlugin = new Elysia().use(
  jwt({
    name: "jwt",
    secret: process.env.SECRET_KEY,
  })
);

export { jwtPlugin };

Script:

bun build ./src/index.ts --outdir ./build --target=node