EACCES:权限被拒绝,mkdir '/root/.npm/sentry-cli'

EACCES: permission denied, mkdir '/root/.npm/sentry-cli'

系统:Ubuntu20.04
NodeJs 版本:v14.17.5
NPM 版本:7.20.6
使用的命令:sudo npm i @nuxtjs/sentry

我正在尝试安装 @nuxtjs/sentry 并收到此消息:

code 1 npm ERR! command failed npm ERR! command sh -c node scripts/install.js npm ERR! info sentry-cli Downloading from https://downloads.sentry-cdn.com/sentry-cli/1.68.0/sentry-cli-Linux-x86_64 npm ERR! Error: EACCES: permission denied, mkdir '/root/.npm/sentry-cli'

npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2021-08-21T09_51_43_400Z-debug.log

使用 yarn add @nuxtjs/sentry 显然已经足够并解决了 OP 的问题。