pnpm 升级

pnpm 的安装源太多了,感觉系统变量都有引入顺序。

今天踩坑记录:

pnpm ,如果最初用npm 装的,可以用npm 升级;

如果最初用brew 装的,得用brew 升级;

如果最初是用corepack 装的得用corepack 升级;

由于项目需要,我今天直接:npm install -g pnpm@10.12.4

然后,就 Error: EACCES: permission denied, access '/usr/local/lib/node_modules'

javascript 复制代码
npm install -g pnpm@10.12.4
npm error code EACCES
npm error syscall mkdir
npm error path /usr/local/lib/node_modules/lib/node_modules/pnpm
npm error errno -13
npm error Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/lib/node_modules/pnpm'
npm error     at async mkdir (node:internal/fs/promises:859:10)
npm error     at async /usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:638:20
npm error     at async Promise.allSettled (index 0)
npm error     at async [reifyPackages] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:336:11)
npm error     at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:141:5)
npm error     at async Install.exec (/usr/local/lib/node_modules/npm/lib/commands/install.js:149:5)
npm error     at async Npm.exec (/usr/local/lib/node_modules/npm/lib/npm.js:208:9)
npm error     at async module.exports (/usr/local/lib/node_modules/npm/lib/cli/entry.js:67:5) {
npm error   errno: -13,
npm error   code: 'EACCES',
npm error   syscall: 'mkdir',
npm error   path: '/usr/local/lib/node_modules/lib/node_modules/pnpm'
npm error }
npm error
npm error The operation was rejected by your operating system.
npm error It is likely you do not have the permissions to access this file as the current user
npm error
npm error If you believe this might be a permissions issue, please double-check the
npm error permissions of the file and its containing directories, or try running
npm error the command again as root/Administrator.

改变文件的权限:

  1. First check who owns the directory
javascript 复制代码
ls -la /usr/local/lib/node_modules

它拒绝访问,因为节点模块文件夹归root所有。

因此,需要将root更改为您的用户,但首先运行下面的命令来检查当前用户

在控制台输入:id -un OR whoami

然后去改变owner

javascript 复制代码
sudo chown -R $USER /usr/local/lib/
sudo chown -R $USER /usr/local/bin/
sudo chown -R $USER /usr/local/share/

再检查文件所属权:

然后我再执行 sudo npm install -global pnpm

呃,这。

脑子里忽然闪过一丢灵光,感觉是系统变量引入顺序的问题。我看公司的这台电脑里是装了brewcorepack

我就试了试:brew 结果和 npm 升级 pnpm 一样。

最后我试了试corepack

javascript 复制代码
corepack enable pnpm
corepack use pnpm@latest-10

然后就好了

javascript 复制代码
pnpm -v
10.12.4

然后我开始装包:pnpm install
pnpm install gives no such file or directory, mkdir '/home/vsts error.

javascript 复制代码
 ENOENT  ENOENT: no such file or directory, mkdir '/home/vsts'

pnpm: ENOENT: no such file or directory, mkdir '/home/vsts'
    at async Object.mkdir (node:internal/fs/promises:859:10)
    at async createNewStoreController (/Users/edy/.cache/node/corepack/v1/pnpm/10.12.4/dist/pnpm.cjs:101790:7)

通过搜索找到答案:手动设置路径:pnpm config set store-dir /path/to/pnpm/store/v3.

Make sure that the path actually exists.

参考资料:https://github.com/pnpm/pnpm/issues/4936

设置路径后,再次装包

pnpm no such file or directory, mkdir '/path'

javascript 复制代码
 ENOENT  ENOENT: no such file or directory, mkdir '/path'

pnpm: ENOENT: no such file or directory, mkdir '/path'
    at async Object.mkdir (node:internal/fs/promises:859:10)
    at async createNewStoreController (/Users/edy/.cache/node/corepack/v1/pnpm/10.12.4/dist/pnpm.cjs:101790:7)
    at async installDeps (/Users/edy/.cache/node/corepack/v1/pnpm/10.12.4/dist/pnpm.cjs:159048:21)

找到答案:pnpm config set store-dir ~/pnpm

参考资料:https://blog.csdn.net/qq_37655530/article/details/129228561

哎,终于搞好了。

参考资料:

https://stackoverflow.com/questions/48910876/error-eacces-permission-denied-access-usr-local-lib-node-modules

https://github.com/pnpm/pnpm/issues/4936

https://blog.csdn.net/qq_37655530/article/details/129228561

相关推荐
f***a3461 小时前
node.js+npm的环境配置以及添加镜像(保姆级教程)
arcgis·npm·node.js
一直在学习的小白~19 小时前
npm发布脚手架流程
前端·npm·node.js
万万君1 天前
npm quick start for beginner
前端·npm·node.js
lpfasd1233 天前
Windows下使用nvm-windows管理Node.js版本及npm配置全指南
windows·npm·node.js
jenchoi4136 天前
【2025-11-22】软件供应链安全日报:最新漏洞预警与投毒预警情报汇总
网络·安全·web安全·网络安全·npm
种时光的人6 天前
关于人人开源框架renren-fast-vue前端npm install安装报错的问题解决方法
前端·vue.js·npm
疯狂踩坑人6 天前
【前端工程化】一文看懂现代Monorepo(npm)工程
前端·npm·前端工程化
要加油哦~6 天前
nrm | npm 的镜像管理工具
前端·npm·node.js·nrm
艾小码6 天前
从源码到npm:手把手带你发布Vue 3组件库
前端·vue.js·npm
Caster_Z7 天前
WinServer安装NPM(Nginx Proxy Manager),并设置反向代理和开启https
前端·nginx·npm