装机常用的脚手架/模板 yeoman/yo

自己写的脚手架以及在线模板存档
更新于: 2023-10-14 14:48:58

🦜 基本安装语法

## typescript 包
git clone git@github.com:afeiship/generator-typescript.git
cd generator-typescript
npm i && npm link

📗 模板列表

名称描述备注
boilerplate-react-ts-componentReactComponent 组件Typescript 版的组件
boilerplate-react-js-componentReactComponent 组件Javascript 版的组件
boilerplate-wsuiSCSS组件库唯一的样板文件

🌱 脚手架列表

名称描述备注
generator-react-componentReactComponent 组件可以生成 Typescript/Javascrip 版的 React 组件
generator-wsuiSCSS组件库平时用到的css可以做成组件包

yo报错问题

解决方案: yarn global add inquirer@^8.2.6,参考了这里

$ yo --version
/Users/aric/.config/yarn/global/node_modules/inquirer/lib/utils/screen-manager.js:4
const wrapAnsi = require('wrap-ansi');
                 ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/aric/.config/yarn/global/node_modules/wrap-ansi/index.js from /Users/aric/.config/yarn/global/node_modules/inquirer/lib/utils/screen-manager.js not supported.
Instead change the require of index.js in /Users/aric/.config/yarn/global/node_modules/inquirer/lib/utils/screen-manager.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/aric/.config/yarn/global/node_modules/inquirer/lib/utils/screen-manager.js:4:18)
    at Object.<anonymous> (/Users/aric/.config/yarn/global/node_modules/inquirer/lib/prompts/base.js:14:23)
    at Object.<anonymous> (/Users/aric/.config/yarn/global/node_modules/inquirer/lib/prompts/list.js:11:14)
    at Function.promptModule.restoreDefaultPrompts (/Users/aric/.config/yarn/global/node_modules/inquirer/lib/inquirer.js:61:33)
    at Object.inquirer.createPromptModule (/Users/aric/.config/yarn/global/node_modules/inquirer/lib/inquirer.js:72:16)
    at Object.<anonymous> (/Users/aric/.config/yarn/global/node_modules/inquirer/lib/inquirer.js:84:28)
    at Object.<anonymous> (/Users/aric/.config/yarn/global/node_modules/yeoman-environment/lib/adapter.js:1:18)
    at Object.<anonymous> (/Users/aric/.config/yarn/global/node_modules/yeoman-environment/lib/environment.js:27:25)
    at Object.<anonymous> (/Users/aric/.config/yarn/global/node_modules/yo/lib/router.js:8:27)
    at Object.<anonymous> (/Users/aric/.config/yarn/global/node_modules/yo/lib/cli.js:14:16) {
  code: 'ERR_REQUIRE_ESM'
}

参考