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

error: unable to resolve module ~/utils #1610

Closed
MagnumGoYB opened this issue Nov 30, 2024 · 4 comments
Closed

error: unable to resolve module ~/utils #1610

MagnumGoYB opened this issue Nov 30, 2024 · 4 comments

Comments

@MagnumGoYB
Copy link

Using an drizzle-orm:
image
image

This will result in an error :
image
image

That's ok :
image

tsconfig.json :
image

@fredr
Copy link
Member

fredr commented Dec 9, 2024

What does your file structure look like? where is the utils folder relative to the tsconfig.json? does it for instance work if you change it to this?

      "~utils/*": ["./utils/*"],

and import it as ~utils/columns.helpers?

@MagnumGoYB
Copy link
Author

MagnumGoYB commented Dec 10, 2024

What does your file structure look like? where is the utils folder relative to the tsconfig.json? does it for instance work if you change it to this?

      "~utils/*": ["./utils/*"],

and import it as ~utils/columns.helpers?

The paths entry in my tsconfig.json is configured "~/*": "./*"
this configuration cannot override "~/utils /*": "./ utils/*"?

@MagnumGoYB
Copy link
Author

What does your file structure look like? where is the utils folder relative to the tsconfig.json? does it for instance work if you change it to this?

      "~utils/*": ["./utils/*"],

and import it as ~utils/columns.helpers?

I tried it, but it still doesn't work.

@fredr
Copy link
Member

fredr commented Jan 13, 2025

What does your filestructure look like? Where is the utils folder in relation to your encore app?

I tested with the hello world example, updated tsconfig.json as you first did:

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "compilerOptions": {
    /* Basic Options */
    "lib": ["ES2022"],
    "target": "ES2022",
    "module": "ES2022",
    "types": ["node"],
    "paths": {
      "~/*": ["./*"],
      "~encore/*": ["./encore.gen/*"]
    },

    /* Workspace Settings */
    "composite": true,

    /* Strict Type-Checking Options */
    "strict": true,

    /* Module Resolution Options */
    "moduleResolution": "bundler",
    "allowSyntheticDefaultImports": true,
    "isolatedModules": true,
    "sourceMap": true,

    "declaration": true,

    /* Advanced Options */
    "forceConsistentCasingInFileNames": true,
    "skipLibCheck": true
  }
}

Then I added a folder called utils on the same level as encore.app, and created a file within that folder called column.helpers.ts.

I could then import it via ~/utils/column.helpers.

I'm not sure if we have fixed anything recently regarding this, or if there is something else that causes the problem here. But maybe you could provide a example app in a git-repo that reproduces the problem.

Please also make sure to run the latest version of encore, you can update by running encore version update

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

2 participants