Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"vue create" in current directory #1509

Closed
tajnymag opened this issue Jun 7, 2018 · 14 comments
Closed

"vue create" in current directory #1509

tajnymag opened this issue Jun 7, 2018 · 14 comments

Comments

@tajnymag
Copy link

tajnymag commented Jun 7, 2018

What problem does this feature solve?

Currently the only option, I'm aware of, to create a new project is to let vue-cli create it's folder from scratch somewhere in the current directory as a subfolder. I'd like an option to create the project in the directory where vue-cli command was invoked.

What does the proposed API look like?

# when run without specifiying project's name, vue-cli would use the current dir's name and place all the new files in the current directory
vue create
@andreasvirkus
Copy link

You can pass in an existing directory's name and you'll be prompted whether to overwrite or merge any existing files. Does that not solve the use case already?

@tajnymag
Copy link
Author

tajnymag commented Jun 8, 2018

Well, yes, but it removes for some reason the local dev installation of vue-cli. Is it intended?

@brandon93s
Copy link

brandon93s commented Jun 8, 2018

You can pass in an existing directory's name and you'll be prompted whether to overwrite or merge any existing files. Does that not solve the use case already?

One limitation of this is folder names that aren't valid project names. For instance, I may have an App.UI folder where I want to create my Vue project. Currently, this isn't possible. You have to vue create app-name inside of the folder, and then copy the contents of the App.UI/app-name folder back out to the root App.UI folder.

Possible syntax:

# Syntax
vue create [options] <app-name> [folder-name]

# Example - Default to .\app-name folder
vue create app-name

# Example - Current Folder
vue create app-name .

# Example - Specified Folder
vue create app-name .\App.UI\

It could also just be a new option with the same behaviors as described above:

Options: 

  -l, --location     Use specified location when creating project

@haoqunjiang
Copy link
Member

Creating project in current directory is already supported by running vue create .
(#916)
As for the folder naming issue, I think this thread facebook/create-react-app#2165 (comment) has given some very persuasive arguments.

@glenndevenish
Copy link

you can't do this with vue ui - it just throws an error if the folder already exists.

New issue?

@goldengecko
Copy link

you can't do this with vue ui - it just throws an error if the folder already exists.

Yeah, I got this error too. It gave me a warning that the folder already exists at the start of the process and asked me if I wanted to overwrite it, so I said no, but then at the end when I went to create, it said the folder already exists and wouldn't continue (v3.5.1)

haoqunjiang pushed a commit that referenced this issue Jun 18, 2019
…[ci skip]

In #1509 it is shown that a new project can be created in the an existing directory. This is a common scenario (e.g. creating a repo on GitHub, cloning it, and then running `vue create`). This commit makes this functionality more well known.
@AndrewBro
Copy link

Just try
vue create .

@iostreamer-X
Copy link

This works but if one has a folder with a preexisting package.json, vue create . simply hijacks it.
This probably is very niche, but I wanted to have a monorepo and I built my server side first and then tried adding the client side stuff.

@spaceneenja
Copy link

If you don't have the Vue CLI installed globally you can still use vue create fairly easily.

npx -p @vue/cli -- create my-vue-app

It takes a while so go grab a latte or something.

You can also install it (again) as a devDependency in your new app to use vue add etc...

@ereztdev
Copy link

vue create . works 100%

@quangv
Copy link

quangv commented Apr 5, 2020

I had thought vue create . would work, but turns out if you're in a parent directory and do vue create existingProject you'd get more prompts:

vue-create_Capture

I expected vue create . and vue create existingProject to be the same.

@Adnan-Bacic
Copy link

Adnan-Bacic commented Dec 1, 2020

If you don't have the Vue CLI installed globally you can still use vue create fairly easily.

npx -p @vue/cli -- create my-vue-app

It takes a while so go grab a latte or something.

You can also install it (again) as a devDependency in your new app to use vue add etc...

this is the only thing that worked for me. i wanted to avoid installing the vue cli globally since the yarn docs said it was a bad idea to globally install packages, because you dont get the cli version in the package.json file: https://classic.yarnpkg.com/en/docs/cli/add#toc-caveats
by installing it to every project you get the cli version in your dependencies, which is nice.

also i found
npx vue create
to be much faster than
npx @vue/cli create

@Subilan
Copy link

Subilan commented Dec 31, 2020

However, vue create . doesn't work if the current directory is named with capital letters. Although this is surely intended, I think the usage of vue create <project-name> [location (relative or absolute)] is better as it allows the difference between the project's name and the directory's name.
image

@0xecho
Copy link

0xecho commented Apr 8, 2022

Yeah, if the folder naming doesn't follow the package naming conventions, you have to 1. rename the folder, 2. create the app, 3. rename the folder back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests