Ubuntu create-react-app fails with permission denied

前端 未结 6 2085
独厮守ぢ
独厮守ぢ 2021-02-08 12:32

I\'m getting a weird error:

Unhandled rejection Error: EACCES: permission denied, mkdir \'/home/ubuntu/.npm/_cacache/index-v5/14/36\'atus

I jus

6条回答
  •  天涯浪人
    2021-02-08 13:29

    Check the owner of the file with ls -l /problem/dir/. The owner is probably set to root, instead of myUserName (i.e. TWoody).

    You will want to change owner of the .npm/ globally first with chown:

    sudo chown -R $USER: ~/.npm/.

    And if this issue has crept into other /build/ directories after running npm run build, you can go to those directories and run the same command:

    sudo chown -R $USER: ./problem/dir/

    Note that the chown command is using the -R flag to change the user ID and/or group ID for the hierarchies rooted in the files instead of just the files themselves. Also note that the argument $USER: is taking your user name (i.e. myUserName, TWoody) and replacing the "group" ID (the second argument of null) of root.

提交回复
热议问题