arco-cli icon indicating copy to clipboard operation
arco-cli copied to clipboard

yarn add:component button 生成的模板没有替换组件名

Open seepine opened this issue 3 years ago • 3 comments

  1. 刚刚重新arco-cli init的项目
  2. 运行yarn add:component button,生成的文件没有替换成输入的button
  3. 手动替换后运行,控制台报错Uncaught ReferenceError: exports is not defined

image image

seepine avatar Jun 30 '22 15:06 seepine

os:win10 node:16.13.1 npm:8.1.2

有条件的话win10下测一下吧

seepine avatar Jun 30 '22 15:06 seepine

我这边没有 windows 环境,方便的话可以排查一下可以给这个仓库提个 PR。添加组件的脚本位于项目的 scripts/add-component.js

Helium-Z avatar Jul 01 '22 02:07 Helium-Z

我这边没有 windows 环境,方便的话可以排查一下可以给这个仓库提个 PR。添加组件的脚本位于项目的 scripts/add-component.js

macos可以替换名字,名字正确但是依然报错 image image

yanbowe avatar Jul 04 '22 07:07 yanbowe

我这边没有 windows 环境,方便的话可以排查一下可以给这个仓库提个 PR。添加组件的脚本位于项目的 scripts/add-component.js

macos可以替换名字,名字正确但是依然报错 image image

请问解决了吗

bqzhaoyan avatar Jan 10 '23 09:01 bqzhaoyan

babel.config.js把这行注释一下

在 2023-01-18 17:18:22,"Rider" @.***> 写道:

KPI 项目是真的辣鸡, 代码都跑不起来!

windows环境下把 scripts/add-components.js 中的代码替换成如下就可以替换模板了

//oldconstcomponentName=process.argv[2];consttemplatePath=path.resolve(__dirname,"template");consttargetComponentPath=path.resolve(__dirname,../components/${componentName});consttargetStoryPath=path.resolve(__dirname,../stories);//newconstcomponentName=process.argv[2];consttemplatePath=path.resolve(__dirname,"template").replace(/\/g,"/");consttargetComponentPath=path.resolve(__dirname,../components/${componentName}).replace(/\/g,"/");consttargetStoryPath=path.resolve(__dirname,../stories).replace(/\/g,"/");

然而还是运行不起来,dev 运行还是报下面的错

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

bqzhaoyan avatar Jan 19 '23 06:01 bqzhaoyan