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

Dependency not included: @sanity/client missing after running pnpm create sanity@latest .. command #7834

Open
bozzhik opened this issue Nov 18, 2024 · 0 comments

Comments

@bozzhik
Copy link

bozzhik commented Nov 18, 2024

Describe the bug

When creating a new Sanity project using the following command:

pnpm create sanity@latest -- --template clean --create-project "project" --dataset production

The @sanity/client package is not added to the package.json dependencies. Once npx sanity@latest typegen generate is executed, building or deploying the project, triggers a TypeScript error Type error: Invalid module name in augmentation, module '@sanity/client' cannot be found.

To Reproduce

Steps to reproduce the behavior:

  1. Create a new Next.js app. My project uses ▲ Next.js 15.0.3 (Turbopack):

    pnpm create next-app@latest --ts
  2. Run the following command to create a new Sanity project:

    pnpm create sanity@latest -- --template clean --create-project "mueller" --dataset production
  3. Answer the following prompts during the setup process:

    ? Would you like to add configuration files for a Sanity project in this Next.js folder? Yes
    ╭────────────────────────────────────────────────────────────╮
    │                                                            │
    │ It looks like you are using Next.js 15 and React 19        │
    │ Please read our compatibility guide.                       │
    │ https://www.sanity.io/help/react-19                        │
    │                                                            │
    ╰────────────────────────────────────────────────────────────╯
    ? Do you want to use TypeScript? Yes
    ? Would you like an embedded Sanity Studio? Yes
    ? What route do you want to use for the Studio? /studio
    ? Select project template to use Blog (schema)
    ? Would you like to add the project ID and dataset to your .env.local file? Yes
    
  4. Inspect the package.json file. The @sanity/client package is missing.

  5. Generate types using the command:

    npx sanity@latest typegen generate
  6. Attempt to build the project. An error occurs due to the missing @sanity/client package:

    ./sanity.types.ts:182:16
    Type error: Invalid module name in augmentation, module '@sanity/client' cannot be found.
    

Expected behavior

The @sanity/client package should be included in the package.json dependencies when creating a new project, as it is required for type generation and proper deployment.

Example of running the command where the package was not added

Screenshots

Example error during deployment:

image

Which versions of Sanity are you using?

@sanity/cli (global)  3.64.1 (up to date)
@sanity/image-url      1.1.0 (up to date)
@sanity/vision        3.64.1 (up to date)
sanity                3.64.1 (up to date)

What operating system are you using?

Windows 11 Pro 22H2

Which versions of Node.js / npm are you running?

v20.18.0 (node)
10.8.2 (npm)

Additional context

Adding @sanity/client manually to the package.json file resolves the issue:

pnpm add @sanity/client

Commit fixing the issue by adding the missing package

This package should be included by default when setting up a new project using the pnpm create sanity@latest command.

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