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

Frontend Missing Lib\utils.ts #3

Open
MetaNets369 opened this issue Jul 23, 2024 · 1 comment
Open

Frontend Missing Lib\utils.ts #3

MetaNets369 opened this issue Jul 23, 2024 · 1 comment

Comments

@MetaNets369
Copy link

Issue Description

The Frontend app is missing frontend/src/lib/utils.ts

The utils serves as import for button.tsx (import { cn } from "@/lib/utils")
Imported by ./src/app/page.tsx

My Solution:

Create the file frontend/src/lib/utils.ts with contents:

export function cn(...classes: string[]) {
return classes.filter(Boolean).join(' ');
}

Resolves the issue.

The original error is:

Failed to compile
./src/components/ui/button.tsx:5:0
Module not found: Can't resolve '@/lib/utils'
3 | import { cva, type VariantProps } from "class-variance-authority"
4 |

5 | import { cn } from "@/lib/utils"
6 |
7 | const buttonVariants = cva(
8 | "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-950 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 dark:ring-offset-gray-950 dark:focus-visible:ring-gray-300",

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./src/app/page.tsx

@MetaNets369
Copy link
Author

On closer inspection:

The .gitignore file has lib/ listed under the "Distribution / packaging" section, which is causing the frontend/src/lib/utils.ts file to be ignored because lib/ is a parent directory.

To resolve this, you can either:

Remove lib/ from .gitignore:

If you don't need to ignore the lib/ directory for other purposes, you can remove or comment out the lib/ line from your .gitignore file.

Add an Exception for the Specific File:

You can add an exception in the .gitignore file to explicitly include frontend/src/lib/utils.ts.

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