question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find module when using 2 different schemas with 2 different folders

See original GitHub issue

I’m not sure if related to https://github.com/kristiandupont/kanel/issues/15 , but feel free to close this one if it is.

init-db.sql

CREATE SCHEMA test1;
CREATE SCHEMA test2;

CREATE TABLE test1.users (
    id integer DEFAULT nextval('test1.users_id_seq'::regclass) PRIMARY KEY
);

CREATE TABLE test2.user_managers (
    id integer DEFAULT nextval('test2.user_managers_id_seq'::regclass) PRIMARY KEY,
    user_id integer REFERENCES test1.users(id)
);

So basically just 2 schemas with the other one pointing to other one.

.kanelrc.js

const path = require("path");

module.exports = {
  // connection: {},
  filenameCasing: "dash",
  typeCasing: "pascal",
  preDeleteModelFolder: true,

  schemas: [
    {
      name: "test1",
      modelFolder: path.join(__dirname, "models", "test1"),
    },
    {
      name: "test2",
      modelFolder: path.join(__dirname, "models", "test2"),
    },
  ],
};

Output: ./models/test2/user-managers.ts

// Automatically generated. Don't change this file manually.

import { UsersId } from './users'; // <-- ERROR HERE! Refers to same folder, even though the UsersId is in "test1".

export type UserManagersId = number & { __flavor?: 'user_managers' };

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
kristiandupontcommented, Aug 16, 2022

This should finally be addressed 😃

There is a premajor version out that should fix this issue. There are significant breaking changes though, and the API is not final so feel free to experiment if you like. The documentation is work in progress still, you can start here: https://github.com/kristiandupont/kanel/blob/v3/docs/configuring.md

1reaction
kristiandupontcommented, Jun 1, 2022

Sorry, I guess this problem remains. I am doing some updates these days, so I will try and see if I can look into this as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node JS cannot find module error for file in another folder
var schemas = require('./folder/schema');. i get an error Cannot find module whats happening? Edit1 : I got rid of the error by using...
Read more >
Nuxt project info - GitHub
nuxt.config.md Error: Cannot find module '../../packages/schema/schema/config.schema.json' Require stack: - C:\Users\vidar\Projekte\Developement ...
Read more >
cannot find module [Node npm Error Solved] - freeCodeCamp
To fix the error, you need to install the package that is absent in your project directory – npm install package-name or yarn...
Read more >
jsconfig.json Reference - Visual Studio Code
js doesn't reference a file b.ts explicitly (either using import or CommonJS modules), there is no common project context between the two files....
Read more >
Cannot find a database object in Database Explorer - JetBrains
Step 1. Refresh the database state · Step 2. Verify that the necessary schemas are selected · Step 3. Force refresh schema information...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found