I'm having two problems with my code. First, I can run the front-end part without any problems. I can access the site, there is no problem with that. But when I enter the command "npm run dev" to run the back-end part, I get
PS C:\Users\skrpn\OneDrive\Masaüstü\honeytype\web\backend> npm run dev
> monkeytype-backend@1.14.3 dev
> ts-node-dev ./src/server.ts -- --inspect --transpileOnly
'ts-node-dev' is not recognized as an internal or external command,
operable program or batch file.
My second problem is that I have a problem with firebase-admin defined in server.ts that I don't know what it is. I am posting the error below. I don't know why I got it and what I should do.
import "dotenv/config";
import admin, { ServiceAccount } from "firebase-admin";
// @ts-ignore
import serviceAccount from "./credentials/serviceAccountKey.json"; // eslint-disable-line require-path-exists/exists
import * as db from "./init/db";
import jobs from "./jobs";
import { getLiveConfiguration } from "./init/configuration";
import { initializeDailyLeaderboardsCache } from "./utils/daily-leaderboards";
import app from "./app";
import { Server } from "http";
import { version } from "./version";
import { recordServerVersion } from "./utils/prometheus";
import * as RedisClient from "./init/redis";
import { initJobQueue } from "./tasks/george";
import Logger from "./utils/logger";
async function bootServer(port: number): Promise<Server> {
try {
Logger.info(`Starting server version ${version}`);
Logger.info(`Starting server in ${process.env.MODE} mode`);
Logger.info(`Connecting to database ${process.env.DB_NAME}...`);
await db.connect();
Logger.success("Connected to database");
Logger.info("Initializing Firebase app instance...");
admin.initializeApp({
credential: admin.credential.cert(
serviceAccount as unknown as ServiceAccount
),
});
Logger.success("Firebase app initialized");
Logger.info("Fetching live configuration...");
const liveConfiguration = await getLiveConfiguration();
Logger.success("Live configuration fetched");
Logger.info("Connecting to redis...");
await RedisClient.connect();
if (RedisClient.isConnected()) {
Logger.success("Connected to redis");
Logger.info("Initializing task queues...");
initJobQueue(RedisClient.getConnection());
Logger.success("Task queues initialized");
}
initializeDailyLeaderboardsCache(liveConfiguration.dailyLeaderboards);
Logger.info("Starting cron jobs...");
jobs.forEach((job) => job.start());
Logger.success("Cron jobs started");
recordServerVersion(version);
} catch (error) {
Logger.error("Failed to boot server");
Logger.error(error);
return process.exit(1);
}
return app.listen(PORT, () => {
Logger.success(`API server listening on port ${port}`);
});
}
const PORT = parseInt(process.env.PORT ?? "5005", 10);
bootServer(PORT);
I tried using nodemon to fix the problem with "npm run dev". There was no change. I don't know what the problem is with the firebase-admin part either. I did the whole installation without any problems.
Also, when I start with nodemon, the command prompt enters the loop. I don't know if it will work for the solution, but I wanted to say it.