Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Import Model from NPM Module in ZenStack #2015

Open
ABouque opened this issue Feb 25, 2025 · 0 comments
Open

Unable to Import Model from NPM Module in ZenStack #2015

ABouque opened this issue Feb 25, 2025 · 0 comments

Comments

@ABouque
Copy link

ABouque commented Feb 25, 2025

Hi,

I'm encountering an issue when trying to import a model from an NPM package into my ZenStack project. The import works fine when using a relative path, but fails when using an NPM module. The error message explicitly states:

Cannot find model file {CORRECT PATH}

Steps to Reproduce:

  1. I created a ZenStack project with workspaces and added a package containing a .zmodel file.
  2. Attempted to import the model in my ZenStack schema:
    import "my-npm-package/schema.zmodel"; // Fails
  3. Ran the ZenStack CLI:
    npx zenstack generate

Expected Behavior:

ZenStack should correctly resolve and use the imported model from the NPM module.

Actual Behavior:

  • When using a relative path (import "../../node_modules/my-npm-package/schema.zmodel";), the import works as expected.
  • When using the package (import "my-npm-package/schema.zmodel";), ZenStack throws the following error:
    Cannot find model file {CORRECT PATH}
    
    (where {CORRECT PATH} is the actual, valid path where the model exists inside node_modules).

Environment:

  • ZenStack Version: 2.11.6
  • Node.js Version: 20.11.0
  • NPM Version: 10.2.4
  • OS: Windows
  • Database : Postgresql

Reproducible Example:

To make it easier to debug, I’ve created a minimal reproducible example on StackBlitz:
👉 https://stackblitz.com/edit/stackblitz-starters-vtmmfxt3?file=package.json

Additional Context:

  • The package is correctly installed in node_modules through workspaces.
  • Other parts of my application can correctly import it.
  • The issue seems to be related to how ZenStack resolves module paths.

Any guidance or workaround would be greatly appreciated! Thanks in advance for your help.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant