Permission denied error when trying to install pnpm via Corepack as node user

未关闭
#1,732 12 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
58/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
docker, node.js

调研方向

首先,使用文档中针对 node:lts-alpine 的 Docker 命令以及非特权用户 -u node 重现该失败。检查镜像如何配置 Corepack 和可写路径;当 corepack enable 以 node 身份成功执行,并且文档中的 pnpm install 流程无需 root 即可正常工作时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

permissions

Environment

  • Node.js Version: 16.15.0
  • Image Tag: lts-alpine

Expected Behavior

I should be able to install pnpm using Corepack as a non-privilegied user.

Current Behavior

When I try to install pnpm via Corepack (corepack enable) as non-privilegied user (-u node), I get the following error:

/app $ corepack enable
Internal Error: EACCES: permission denied, symlink '../lib/node_modules/corepack/dist/pnpm.js' -> '/usr/local/bin/pnpm'
Error: EACCES: permission denied, symlink '../lib/node_modules/corepack/dist/pnpm.js' -> '/usr/local/bin/pnpm'
/app $ 

Running corepack enable as root work as expected.

docker run -it -v $(pwd):/app node:lts-alpine /bin/sh

image

Steps to Reproduce

  1. Create an empty project with the following package.json. The packageManager property is important here.

    {
        "name": "docker-node-pnpm",
        "version": "1.0.0",
        "private": true,
        "packageManager": "pnpm@7.1.7"
    }
    
  2. Run the container as a non-privilegied user: docker run -it -v $(pwd):/app -u node node:lts-alpine /bin/sh

  3. cd /app

  4. corepack enable <-- This should fail

  5. corepack prepare

  6. pnpm install

主要语言
Dockerfile
星标
8.6k
派生
2k
平均合并
10 小时 19 分钟
30 天内合并 PR
16

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

nodejs/docker-node 的其他 Issue

查看 nodejs/docker-node 的全部 Issue

相似的 Issue

更多 DevOps Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。