Skip to content

Module not found: Can't resolve './client' #1969

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

Open
cheehong1030 opened this issue Apr 21, 2025 · 6 comments
Open

Module not found: Can't resolve './client' #1969

cheehong1030 opened this issue Apr 21, 2025 · 6 comments

Comments

@cheehong1030
Copy link

Description
When using code generated by @hey-api/openapi-ts, I'm encountering a module resolution error. The generated code imports from a ./client module that doesn't exist.

Steps to reproduce
Configure @hey-api/openapi-ts with the provided config file
Run the openapi-ts to generate sdk
Import and use the generated code in a project
run the project

Error

Module not found: Can't resolve './client'
  1 | // This file is auto-generated by @hey-api/openapi-ts
  2 |
> 3 | import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client';
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  4 | import type { ClientOptions } from './types.gen';
  5 |
  6 | /**

Configuration

// openapi-ts.config.ts
import { defaultPlugins, defineConfig } from '@hey-api/openapi-ts';

export default defineConfig({
    input: 'http://localhost/api/swagger/openapi.json',
    output: {
        format: 'prettier',
        lint: 'eslint',
        path: './src/client',
    },
    plugins: [
        ...defaultPlugins,
        {
            bundle: true,
            name: '@hey-api/client-axios',
            runtimeConfigPath: './src/requestSetting.ts',
        },
        {
            enums: 'typescript',
            name: '@hey-api/typescript',
        },
        {
            name: '@hey-api/schemas',
            type: 'json',
        },
        {
            asClass: true,
            serviceNameBuilder: '{{name}}',
            name: '@hey-api/sdk',
        },
        '@hey-api/sdk',
        '@tanstack/react-query',
    ],
});

Image

Please correct me if there is any wrong configuration

@mrlubos
Copy link
Member

mrlubos commented Apr 21, 2025

@cheehong1030 I see the folder in your screenshot, is it empty?

@cheehong1030
Copy link
Author

No, The contents of the folder are normal and there are no typescript errors. But seem he can't find the ./client folder. Is this error about typescript configuration?

@mrlubos
Copy link
Member

mrlubos commented Apr 21, 2025

Probably! Please create a reproducible example if you want me to have a look

@cheehong1030
Copy link
Author

Try this
http://github.com/cheehong1030/example-openapi-ts

Image

@mrlubos
Copy link
Member

mrlubos commented Apr 22, 2025

Can you try with bundleSource_EXPERIMENTAL?

@cheehong1030
Copy link
Author

cheehong1030 commented Apr 22, 2025

New error
Seems this error from the bundle configuration

Image

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