Search code examples
vue.jsnpx

Is there any npx create react app equivalent for vue cli?


I want to install vue for my project through npx, not globally and to be sure that I have the latest version of vue.js, just like is done in react. What is the command in the terminal to achieve that?


Solution

  • npx @vue/cli create

    Vue CLI (@vue/cli) is the equivalent package, which could be run with npx like this:

    npx @vue/cli create --default my-vue-app
    
    • Vue CLI 4's default template is a Vue 2 project with Webpack 4. Remove --default flag for version prompts.
    • Vue CLI 5's (5.0.0-rc.2 or newer) default template is a Vue 3 project with Webpack 5. Remove --default flag for version prompts.
    • Vue CLI is now in maintenance mode, so the following npm-init commands should be preferred instead.

    npm init vue

    The official recommended starter:

    # npm 6.x
    npm init vue my-vue-app --default
    
    # npm 7+, extra double-dash is needed:
    npm init vue my-vue-app -- --default
    
    # yarn
    yarn create vue my-vue-app --default
    
    # pnpm
    pnpm create vue my-vue-app -- --default
    
    • The default template is a Vue 3 project that uses Vite. Use @2 version specifier for a Vue 2 project (e.g., npm init vue@2).

    npm init vite

    A similar starter to the one from npm init vue:

    # npm 6.x
    npm init vite my-vue-app --template vue
    
    # npm 7+, extra double-dash is needed:
    npm init vite my-vue-app -- --template vue
    
    # yarn
    yarn create vite my-vue-app --template vue
    
    # pnpm
    pnpm create vite my-vue-app -- --template vue
    
    • The vue template is a Vue 3 project. There is currently no official Vue 2 template integrated with this npm-init command.