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.
# 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
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?
Well, yes, but it removes for some reason the local dev installation of vue-cli. Is it intended?
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
Creating project in current directory is already supported by running vue create .
(https://github.com/vuejs/vue-cli/pull/916)
As for the folder naming issue, I think this thread https://github.com/facebook/create-react-app/issues/2165#issuecomment-301627339 has given some very persuasive arguments.
you can't do this with vue ui - it just throws an error if the folder already exists.
New issue?
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)
Just try
vue create .
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.
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...
vue create .
works 100%
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:
I expected vue create .
and vue create existingProject
to be the same.
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
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.
Most helpful comment
Creating project in current directory is already supported by running
vue create .
(https://github.com/vuejs/vue-cli/pull/916)
As for the folder naming issue, I think this thread https://github.com/facebook/create-react-app/issues/2165#issuecomment-301627339 has given some very persuasive arguments.