Search code examples
next.jsubuntu-22.04next.js14shadcnui

Installing components... EACCES: permission denied, mkdir '/components'


I am using shadcn/ui components to create frontend in my NextJS 14 project. But I am getting this error(ubuntu 22.04), when I try to add any component using following command: npx shadcn-ui@latest add navigation-menu

I have tried this solution also, but still issue persists. Can anyone help me to resolve this?

Expected behavior: It should create a navigation-menu.jsx file under src/components/ui folder if command runs successfully.


Solution

  • It can be a permission issue, in which case, open a terminal in the folder that contains the project and run:

    sudo chmod u+w project-folder-name
    

    Also, as Meet Akbari said, it could be an import aliases issue, problem, in which case you need to update your jsconfig.json accordingly:

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