我正在尝试使用 npm 安装纱线,这是纱线项目本身推荐的。起初我尝试运行 npm install --global yarn
,但由于权限不足而失败,所以我再次尝试使用 sudo npm install --global yarn
。
但这给了我以下结果:
npm info it worked if it ends with ok
npm verb cli [ '/usr/bin/node',
npm verb cli '/usr/bin/npm',
npm verb cli 'install',
npm verb cli '--verbose',
npm verb cli '--global',
npm verb cli 'yarn' ]
npm info using npm@6.14.4
npm info using node@v10.19.0
npm verb npm-session 92d2a6de56a6da3f
npm http fetch GET 304 https://registry.npmjs.org/yarn 194ms (from cache)
npm timing stage:loadCurrentTree Completed in 249ms
npm timing stage:loadIdealTree:cloneCurrentTree Completed in 1ms
npm timing stage:loadIdealTree:loadShrinkwrap Completed in 2ms
npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 3ms
npm timing stage:loadIdealTree Completed in 7ms
npm timing stage:generateActionsToTake Completed in 7ms
npm verb correctMkdir /root/.npm/_locks correctMkdir not in flight; initializing
npm verb lock using /root/.npm/_locks/staging-3a08f0df5026584d.lock for /usr/local/lib/node_modules/.staging
npm timing action:extract Completed in 75ms
npm info lifecycle yarn@1.22.10~preuninstall: yarn@1.22.10
npm info lifecycle yarn@1.22.10~uninstall: yarn@1.22.10
npm verb unbuild rmStuff yarn@1.22.10 from /usr/local/lib/node_modules
npm info lifecycle yarn@1.22.10~postuninstall: yarn@1.22.10
npm timing action:unbuild Completed in 6ms
npm timing action:remove Completed in 6ms
npm timing action:finalize Completed in 2ms
npm timing action:refresh-package-json Completed in 5ms
npm info lifecycle yarn@1.22.10~preinstall: yarn@1.22.10
> yarn@1.22.10 preinstall /usr/local/lib/node_modules/yarn
> :; (node ./preinstall.js > /dev/null 2>&1 || true)
命令以退出代码 1 退出。在 sudo -i
shell 中出现相同的结果。我添加了 --verbose
标志以尝试查看发生了什么,但仍然没有可辨别的错误消息。果然,当我尝试运行它或在它上面使用 which
时并没有安装它。我还检查了 ~/.npm/_logs
并且没有此错误的日志,只有当我尝试在没有 sudo
的情况下运行它时遇到的权限错误的日志。为什么会失败?
使用 Ubuntu 20.04 LTS。
编辑:
我能够在 /root/.npm/_logs
中找到相关的日志文件。它将此显示为错误消息:
error Cannot find module './get-uid-gid.js'
我该如何解决?