npm 升级出现 "Missing write access" 错误
用 npm install -g npm 升级 npm 时出现以下 "Missing write access" 错误。
......
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/npm/node_modules/minipass/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules/npm/node_modules/ignore-walk
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/npm/node_modules/ignore-walk'
......
执行以下代码赋予权限就可以了:
sudo chown -R $USER /usr/local/lib/node_modules