שגיאה: ErrorCaptureStackTrace(err); בהרצה של Radis Data Base, node JS

  • הוסף לסימניות
  • #1
אני מנסה להוסיף נתונים למסד נתונים של Redis שממנו העתקתי: https://redis.io/docs/stack/get-started/tutorials/stack-node זו הסכמה שלי:
import { Entity, Schema } from 'redis-om'
import client from './client.js'
import { router as person_router, router } from '../routers/person_router.js'




/* our entity */
class Person extends Entity {}
const personSchema = new Schema(
Person, {
firstName: {
type: "string",
},
lastName: {
type: "string",
},
age: {
type: "text",
},
pulse_at_rest: { //דופק במנוחה
type: "text",
},
background_diseases_and_medical_limitations: { //מחלות_רקע ומגבלות_רפואיות
type: "string",
},
Working: { //עבודה
type: "string",
},
password: {
type: "string",
},
Preferred_training_time: {//זמן_אימון_מועדף
type: "string",
},
the_duration_of_the_training: {//משך הריצה
type: "text",
},
goal: { //מטרה
type: "string",
},
gender: {//מין
type: "text",
},
height: {
type: "text",
},
Sports_background: {//רקע_ספורט
type: "string",
},

},

)



/* use the client to create a Repository just for Persons */
export const personRepository = client.fetchRepository(personSchema);
/* create the index for Person */
personRepository.createIndex().then(data=> {console.log(data)}).catch(err => {console.log("err", err)})

export default Person

והנה אני משתמש בו:
import { createClient } from 'redis-om';
import { Client } from 'redis-om';
import { personRepository } from './person';

/* pulls the Redis URL from .env */
const url = process.env.REDIS_URL;

/* create a connection to Redis with redis-om */
export const connection = createClient({ url });
connection.connect();

/* create a Client and bind it to the redis-om connection */
const client = new Client().use(connection);

async function fetchData(id) {
const person = await personRepository.fetch(id);
console.log(person); // Log the person data
return person;
// Use the person data here
}

(async () => {
const id = "123455";
const person = await fetchData(id);
person.location = { longitude, latitude };
person.locationUpdated = locationUpdated;
await personRepository.save(person);

let keyName = `${person.keyName}:locationHistory`;
await connection.xAdd(keyName, '*', person.location);
})();

export default client;

אבל כשאני מייבא את הקובץ לקובץ הראשי:
import { router as personRouter } from './routers/person_router.js'

אני מקבל
node:internal/errors:490 ErrorCaptureStackTrace(err); ^
שגיאה [ERR_MODULE_NOT_FOUND]: לא ניתן למצוא את המודול 'C:\Users\hodaya\Downloads\express-redis-om-workshop-main\express-redis-om-workshop-main\om\person' מיובא מ-C:\Users\hodaya \Downloads\express-redis-om-workshop-main\express-redis-om-workshop-main\routers\person_router.js ב-NodeError חדש (צומת:internal/errors:399:5) ב-finalizeResolution (צומת:internal/modules) /esm/resolve:326:11) ב-modulResolve (node:internal/modules/esm/resolve:945:10) ב-defaultResolve (node:internal/modules/esm/resolve:1153:11) ב-nextResolve (node:internal/ modules/esm/loader:163:28) ב-ESMLoader.resolve (node:internal/modules/esm/loader:838:30) ב-ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18) ב-ModuleWrap . (node:internal/modules/esm/module_job:77:40) בקישור (node:internal/modules/esm/module_job:76:36) { code: 'ERR_MODULE_NOT_FOUND' }

מישהו יודע אולי מה הבעיה כאן? ואיך אפשר לתקן את זה?
 
  • הוסף לסימניות
  • #2
הבעיה היא בכלל לא בסכמה או בחיבור למסד הנתונים, הבעיה היא שnode לא מצליח לייבא את הקובץ שצרת, מהודעת השגיאה עצמה לא הבנתי בדיוק מה הבעיה, כפי הנראה לא הכנסת את הנתיב לקובץ בצורה נכונה
 

פרוגבוט

תוכן שיווקי
פרסומת

הצטרפות לניוזלטר

איזה כיף שהצטרפתם לניוזלטר שלנו!

מעכשיו, תהיו הראשונים לקבל את כל העדכונים, החדשות, ההפתעות בלעדיות, והתכנים הכי חמים שלנו בפרוג!

לוח מודעות

הפרק היומי

הפרק היומי! כל ערב פרק תהילים חדש. הצטרפו אלינו לקריאת תהילים משותפת!


תהילים פרק כה

אלְדָוִד אֵלֶיךָ יי נַפְשִׁי אֶשָּׂא:באֱלֹהַי בְּךָ בָטַחְתִּי אַל אֵבוֹשָׁה אַל יַעַלְצוּ אֹיְבַי לִי:גגַּם כָּל קוֶֹיךָ לֹא יֵבֹשׁוּ יֵבֹשׁוּ הַבּוֹגְדִים רֵיקָם:דדְּרָכֶיךָ יי הוֹדִיעֵנִי אֹרְחוֹתֶיךָ לַמְּדֵנִי:ההַדְרִיכֵנִי בַאֲמִתֶּךָ וְלַמְּדֵנִי כִּי אַתָּה אֱלֹהֵי יִשְׁעִי אוֹתְךָ קִוִּיתִי כָּל הַיּוֹם:וזְכֹר רַחֲמֶיךָ יי וַחֲסָדֶיךָ כִּי מֵעוֹלָם הֵמָּה:זחַטֹּאות נְעוּרַי וּפְשָׁעַי אַל תִּזְכֹּר כְּחַסְדְּךָ זְכָר לִי אַתָּה לְמַעַן טוּבְךָ יי:חטוֹב וְיָשָׁר יי עַל כֵּן יוֹרֶה חַטָּאִים בַּדָּרֶךְ:טיַדְרֵךְ עֲנָוִים בַּמִּשְׁפָּט וִילַמֵּד עֲנָוִים דַּרְכּוֹ:יכָּל אָרְחוֹת יי חֶסֶד וֶאֱמֶת לְנֹצְרֵי בְרִיתוֹ וְעֵדֹתָיו:יאלְמַעַן שִׁמְךָ יי וְסָלַחְתָּ לַעֲוֹנִי כִּי רַב הוּא:יבמִי זֶה הָאִישׁ יְרֵא יי יוֹרֶנּוּ בְּדֶרֶךְ יִבְחָר:יגנַפְשׁוֹ בְּטוֹב תָּלִין וְזַרְעוֹ יִירַשׁ אָרֶץ:ידסוֹד יי לִירֵאָיו וּבְרִיתוֹ לְהוֹדִיעָם:טועֵינַי תָּמִיד אֶל יי כִּי הוּא יוֹצִיא מֵרֶשֶׁת רַגְלָי:טזפְּנֵה אֵלַי וְחָנֵּנִי כִּי יָחִיד וְעָנִי אָנִי:יזצָרוֹת לְבָבִי הִרְחִיבוּ מִמְּצוּקוֹתַי הוֹצִיאֵנִי:יחרְאֵה עָנְיִי וַעֲמָלִי וְשָׂא לְכָל חַטֹּאותָי:יטרְאֵה אוֹיְבַי כִּי רָבּוּ וְשִׂנְאַת חָמָס שְׂנֵאוּנִי:כשָׁמְרָה נַפְשִׁי וְהַצִּילֵנִי אַל אֵבוֹשׁ כִּי חָסִיתִי בָךְ:כאתֹּם וָיֹשֶׁר יִצְּרוּנִי כִּי קִוִּיתִיךָ:כבפְּדֵה אֱלֹהִים אֶת יִשְׂרָאֵל מִכֹּל צָרוֹתָיו:
נקרא  2  פעמים
למעלה