• Yeman 搭建脚手架


    一、在全局范围安装 yo

    $ npm install yo --global # or yarn global add yo
    

      

    二、安装对应的 generator

    $ npm install generator-node --global # yarn global add generator-node
    

      

    三、通过 yo 运行 generator [ 生成 yo 的目录结构 ]

    $ mkdir my-module
    $ yo node
    

     

    如果以上报错,请自行执行 npm install

    I'm all done. Running npm install for you to install the required dependencies. If this fails, try running the command yourself.

    四、安装node:cli 

    $ yo node:cli
    

      

    五、将该项目暴露到全局

    $ yarn link

    如果你看到以下内容,说明,项目暴露到全局成功

    info You can now run `yarn link "***你的项目名"` in the projects where you want to use this package and it will be used instead.

     

    六、测试 全局是否可以找到该项目

    $ ***你的项目名 --help  (my-module --help) 

      

    啊哟喂:报错了 -bash: /usr/local/bin/my-module: Permission denied ,看来是没有权限导致的

    解决方案:

    1. 到上一个目录,

    $ cd ..
    

    2. 将该项目授权

    $ sudo chmod -R 777 项目名

    3. 回到项目中

    $ cd my-module
    

    4. 再次查看

    $ my-module --help
    

      

    啊哦,又卡着了, 

    Error: Cannot find module 'meow' ----提示缺少“meow”模版

    1. 安装模版

    $ cnpm install meow # yarn add meow

    2. 再次测试 my-module 

    my-module --help

    如看到以下,则表示成功
      脚手架
    
      Usage
        $ gqx-cli [input]
    
      Options
        --foo  Lorem ipsum. [Default: false]
    
      Examples
        $ gqx-cli
        unicorns
        $ gqx-cli rainbows
        unicorns & rainbows

    七、打开 yeman 网址,选择适合你的 generator 

    $ yarn global add generator webapp (webapp 是我选择的 generator)
    

      

    八、yeman 运行 webapp

    $ yo webapp
    

     

    九、 使用脚手架

    1. 在其他文件夹,新建 my-cli 文件夹
    2. 因为在第六步已经将该文件设置为全局访问,所以可以直接使用
    3. 控制台输入 $ my-module 
    4. 在目录下查看 my-cli内是否有my-module 内包含的文件,如果已经存在则成功

     

  • 相关阅读:
    07java数组、排序算法
    06方法定义及调用、方法重载、命令行参数、可变参数
    04用户交互scanner
    01IDEA新建一个java程序
    05顺序结构、选择结构、循环、、
    【Linux】symbol lookup error: undefined symbol + nm指令定位错误
    linux命令——crontab的使用方法
    WSL2 Ubuntu固定IP,开机启动SSH
    AArch64下编译及使用sigar
    使用last命令找出是谁重启了你的服务器(linux)
  • 原文地址:https://www.cnblogs.com/gqx-html/p/13469497.html
Copyright © 2020-2023  润新知