npm install permission denied (macOS)

前端 未结 6 819
梦谈多话
梦谈多话 2021-02-07 15:08

To install a Bootstrap theme I want to run npm install. However I always receive a permission denied error.

I already tried nvm and then switched with

6条回答
  •  别跟我提以往
    2021-02-07 16:01

    I was having a similar issue, but the accepted answer did not work for me, so I will post my solution in case anyone else comes along needing it.

    I was running npm install in a project cloned from GitHub and during the clone, for whatever reason the write permission was not actually set on the project directory. To check if this is your problem, pull up Terminal and enter the following:

    cd path/to/project/parent/directory
    ls -l
    

    If the directory has user write access, the output will include a w in the first group of permissions:

    drwxr-xr-x  15 user  staff  480 Sep 10 12:21 project-name
    

    This assumes that you're trying to access a project in the home directory structure of the current user. To make sure that the current user owns the project directory, follow the instructions in the accepted answer.

提交回复
热议问题