askorama / orama

🌌 Fast, dependency-free, full-text and vector search engine with typo tolerance, filters, facets, stemming, and more. Works with any JavaScript runtime, browser, server, service!

Home Page:https://docs.orama.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[plugin-data-persistence]: ERR_PACKAGE_PATH_NOT_EXPORTED, Issue with package import

KrishnaManohar1997 opened this issue · comments

Describe the bug

When I'm trying to make use of plugin-data-persistence

import { persistToFile } from '@orama/plugin-data-persistence';

I immediately face an error

    throw new Error(METHOD_MOVED('persistToFile'));
          ^

Error: Function persistToFile has been moved to the "/server" module. 

Import it via "import { persistToFile } from 'orama/plugin-data-persistence/server'". 

I then immediately updated the import to import { persistToFile } from 'orama/plugin-data-persistence/server'
However facing the following import issue
image

I have then managed to remove the import error by changing the import path to
import { persistToFile } from '@orama/plugin-data-persistence/dist/server';

This is leading to the following error

Error: ERR_PACKAGE_PATH_NOT_EXPORTED /Users/DevUser/myCode/nlp/node_modules/@orama/plugin-data-persistence/ ./dist/server /Users/DevUser/myCode/nlp/orama/databaseWrapper.ts
    at throwExportsNotFound ( /Users/DevUser/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:380:9)
    at packageExportsResolve ( /Users/DevUser/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:605:3)
    at packageResolve ( /Users/DevUser/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:746:14)
    at moduleResolve ( /Users/DevUser/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:798:18)
    at Object.defaultResolve ( /Users/DevUser/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:912:11)

I'm using the following command to execute my code
node --trace-warnings --loader ts-node/esm driver.ts

To Reproduce

  1. Installed Orama [Worked fine] (latest version)
  2. Installed plugin-data-persistence latest version
  3. Imported {persistToFile} package from import { restoreFromFile } from '@orama/plugin-data-persistence/dist/server';
  4. Executed the node --loader ts-node/esm driver.ts
  5. Faced with the error Error: ERR_PACKAGE_PATH_NOT_EXPORTE

Expected behavior

I expected the import to work normally, which is failing with importing the package component persistToFile

Environment Info

OS: MacOs Sonoma 14.1.2
Node: v21.5.0
Orama: @orama/orama@2.0.3
Orama/plugin-data-persistence: @orama/plugin-data-persistence@2.0.3 [I've tried using old versions of the Plugin package]

Affected areas

Initialization

Additional context

No response

Three weeks no response :/ I have the same issue.

Hi there, sorry for such a late reply. We're investigating

Quick question @came, @KrishnaManohar1997, are you using this in a CJS module or in an ESM one?

commented

Import is import { persist } from '@orama/plugin-data-persistence' isn't it ?