[Yarn] 為何yarn add會出現EACCES: permission denied?原來只是檔案被上鎖
在react專案資料夾下安裝axios $ yarn add axios 結果跳出以下錯誤,並且axios安裝失敗。 yarn add v1.22.10 warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json . 中間省略... error An unexpected error occurred: "EACCES: permission denied , open '/home/kabuto/react-learn-hook/frontend/yarn.lock'". info If you think this is a bug, please open a bug report with the information provided in "/home/kabuto/react-learn-hook/frontend/yarn-error.log". info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command. 只看後面錯誤訊息,查了Statck Overflow以為是 yarn.lock有執行權限的Bug, 雖然照字面看permission denied也確實如此,於是就用以下指令修改yarn.lock的權限 $ sudo chown -R $USER:$GROUP yarn.lock 當然這次yarn add 就成功了,總覺得強行修改權限不是個好辦法,事實上在Statckoverflow也有人提議乾脆sudo yarn add。 2022/01/15更新: 第二種解法:最保險的情況應該是刪除node