Failed to install components due to EACCES error, permission denied while trying to create directory '/components'

Currently, I am utilizing shadcn/ui components to develop the frontend for my NextJS 14 project. However, upon attempting to add any component using the command:

npx shadcn-ui@latest add navigation-menu
, I encountered an error on Ubuntu 22.04.

Despite trying this solution, the issue persists. Can anyone provide guidance on how to resolve this?

The desired outcome is for a navigation-menu.jsx file to be generated under src/components/ui folder if the command executes successfully.

Answer №1

If you are facing this issue, it may be related to permissions. To resolve this, navigate to the project folder in your terminal and execute the following command:

sudo chmod u+w project-folder-name

Additionally, consider checking for any import alias problems as suggested by Meet Akbari. You can fix this by updating your jsconfig.json file with the following configuration:

{
  "compilerOptions": {
    "paths": { "@/*": ["./*"] }
  }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Eliminate FormData usage from the Next.JS backend application

Looking to replicate the steps outlined in this guide: https://medium.com/@_hanglucas/file-upload-in-next-js-app-router-13-4-6d24f2e3d00f for file uploads using Next.js, encountering an error with the line const formData = await req.formData();. The error ...

Unauthorized access: The defaultCookies variable is not defined in Next-Auth

Has anyone else come across this error message while using next/auth version 3.27.3 in their app? error - unhandledRejection: ReferenceError: defaultCookies is not defined at C:\Users\MAGICSOFT Mike\Desktop\NEW MAGICSOFT\crd-pr ...

An issue arises while trying to retrieve the _id field from MongoDB in a Next.js authentication scenario during the login process and

As I was following a tutorial to set up a blogging site, I integrated NextAuth with Google and MongoDB for user sign-up. Everything seemed to work fine until I encountered an issue when trying to retrieve the _id from MongoDB and assign it to the session u ...

Experiencing trouble with cross-origin resource sharing when attempting to transfer data to my server

"Access to XMLHttpRequest at 'http://localhost:3000/campgrounds/6411f03e718f68104cac045a' (redirected from 'http://localhost:5000/campgrounds') from origin 'http://localhost:3000' has been blocked by CORS policy: Response ...

Having trouble with text decoration not working for a link in Material-UI. Any ideas for a solution?

Currently, I am working on a React/Next.js project and incorporating MUI for the design elements. <Link href="/products"> <ListItem disablePadding> <ListItemButton> <ListItemIcon> ...

The setState function in the useState hook is being called only one time when triggered by an EventListener

Within my functional component, I am utilizing the useState hook to store state. When the user reaches the bottom of the page, I want to dynamically add content. To achieve this, I implemented an EventListener for 'scroll' within a useEffect hook ...

What is causing the TypeError in next-auth when attempting to destructure the 'manager' property of the 'connection' object, which is null?

I encountered an error when connecting to mongo atlas, but everything works fine with a local database. Please refer to the image of the db connection and the terminal error for additional details. dbconnect.ts import mongoose from "mongoose"; ...

Leveraging PostCSS Global Data in Next.js

Utilizing PostCSS along with postcss-preset-env (now integrated into postcss-plugins monorepo) and postcss-custom-media enables the declaration of global breakpoints once, making them accessible within CSS Modules across the project. The documentation for ...

Various static webpages can be displayed using a single URL based on the presence of a cookie

I have two similar pages, with one having an additional element to display while the other does not. These pages are static and do not involve private user data or authentication. My goal is to show one of these pages under the same URL, based on a parame ...

How to extract the parameters separated by slashes from a URL in Next.js

I need some guidance on how to redirect a URL in an express.js configuration. Here's the scenario: The URL is: profile/myname To forward to my page profile.js, I use the following code in my express.js config: server.get('/profile/:username&ap ...

Is it possible to update local state in useSWR without triggering a revalidation?

I recently retrieved some data from a public API using useSWR and now I need to manipulate it. In the past, I would update the state with the API response and then simply overwrite it when performing operations. Now, I want to be able to sort the data by ...

Ways to toggle visibility of menu options in a Next.js application based on user authentication status

I need to conditionally show the logout button only if a user is logged in. Here is my _app.js file: import React from "react"; import App from "next/app"; import Navbar from "../components/navbar"; import Layout from "../components/layouts/mainLayout"; ...

Encountering a getStaticProps error while using Typescript with Next.js

I encountered an issue with the following code snippet: export const getStaticProps: GetStaticProps<HomeProps> = async () => { const firstCategory = 0; const { data }: AxiosResponse<MenuItem[]> = await axios.post( ...

PrismaClientValidationError: The `prisma.user.create()` method was called with incorrect parameters:

I am currently in the process of developing an API using Next.js and Prisma. Within this project, I have defined two models - one for users and another for profiles. My goal is to create a new user along with their profile by fetching data from req.body th ...

The issue of causing a "window is undefined error" persists even after attempts to fix it, ultimately rendering it out of scope

When I try to initialize a const, I encounter a "window is undefined" error in nextjs. To resolve this issue, I have attempted the following code: if (typeof window !== "undefined") { const web3Modal = new Web3Modal({ network: "mainnet&q ...

When integrating Axios with NextJS, ensure to include CORS headers to prevent any missing data

I have set up a NestJS backend with a NextJS frontend, both hosted separately. NestJS Backend To enable CORS in the backend, I included the following code: app.enableCors({ credentials: true, origin: process.env.FRONTEND_URL }); After checking the CORS ...

"Development environment running smoothly for NextJS 14 site, but encountering issues when deployed on Verc

I am encountering an issue with my page (server component) that retrieves data from a route handler (/api/v1/bookings/get) within my application. While everything runs smoothly with next dev --turbo, deploying to Vercel results in the following error: App ...

Error encountered in 'Next.js' at '_next/static/YzkQBtj6rd9b69Th7lZs0/pages/index.js' path

Encountering an error in my Next.js project. www.~~~.com/_next/static/YzkQBtj6rd9b69Th7lZs0/pages/index.js net::ERR_ABORTED 404 (Not Found) It seems that I have set up Next.js on www.~~~.com/beta However, it is trying to call root from www.~~~.co ...

Tips for transferring an image file through formdata to a React/Next.js api

I am attempting to upload an image file to a cloudinary API within a Next.js application: The function calling the API is as follows: async uploadButtonClicked(imageUpload) { const formData = new FormData(); //formData.append('test', ...

The use of JSON.stringify on ArrayData is not updating as expected within the useEffect hook in Next.js

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faSearch, faAmbulance, faAnchor, faPlus, faFloppyDisk, } from '@fortawesome/free-solid-svg-icons'; import { Input, Table, Button, Modal, Moda ...