You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu环境下用yarn创建react-admin应用遇ENOENT错误求助

解决yarn create react-admin时的ENOENT模板目录错误

问题场景

在Ubuntu系统执行yarn create react-admin test-admin,选择JSON Server数据提供者、None认证提供者,未添加资源并选择yarn作为包管理器后,出现错误:

at makeError$1 (/tmp/xfs-9f3e1446/dlx-17795/.pnp.cjs:1962:24) ENOENT: no such file or directory, lstat '/node_modules/create-react-admin/templates/common'

错误栈如下:

at ENOENT (/tmp/xfs-9f3e1446/dlx-17795/.pnp.cjs:1977:10)
at ZipFS.resolveFilename (/tmp/xfs-9f3e1446/dlx-17795/.pnp.cjs:3559:15)
at ZipFS.lstatSync (/tmp/xfs-9f3e1446/dlx-17795/.pnp.cjs:3428:28)
at /tmp/xfs-9f3e1446/dlx-17795/.pnp.cjs:4733:20
at /tmp/xfs-9f3e1446/dlx-17795/.pnp.cjs:5155:60
at ZipOpenFS.getZipSync (/tmp/xfs-9f3e1446/dlx-17795/.pnp.cjs:5284:14)
at ZipOpenFS.makeCallSync (/tmp/xfs-9f3e1446/dlx-17795/.pnp.cjs:5155:17)
at ZipOpenFS.lstatSync (/tmp/xfs-9f3e1446/dlx-17795/.pnp.cjs:4730:17)
at VirtualFS.lstatSync (/tmp/xfs-9f3e1446/dlx-17795/.pnp.cjs:4182:24)

解决方法

1. 切换Yarn到传统node_modules模式

错误源于Yarn PnP虚拟文件系统无法正确解析模板文件路径,切换到传统模式即可:

yarn config set nodeLinker node-modules

之后重新执行创建命令:

yarn create react-admin test-admin

2. 清理Yarn临时缓存

临时目录文件损坏也可能导致该问题,清理后重试:

yarn cache clean
rm -rf /tmp/xfs-*

3. 换用npm创建项目

如果Yarn问题持续,直接用npm尝试:

npx create-react-admin test-admin

后续按提示选择对应选项,最后选npm作为包管理器。

4. 手动初始化项目(备选方案)

若以上方法都无效,手动创建React项目再添加react-admin:

yarn create react-app test-admin
cd test-admin
yarn add react-admin ra-data-json-server

之后按照官方教程修改src/App.js,配置JSON Server数据提供者即可。

内容的提问来源于stack exchange,提问作者zahra boukthir

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 20:43:07