問題
最近測試在 linux 下使用 root 權限執行 npm install 報錯了,錯誤如下:
解決
在執行指令後面添加參數:
--unsafe-perm=true --allow-root
npm install --unsafe-perm=true --allow-root
原因
unsafe-perm
- Default: false if running as root, true otherwise
- Type: Boolean
Set to true to suppress the UID/GID switching when running package scripts. If set explicitly to false, then installing as a non-root user will fail.