Reputation: 222309
As the UmiJS documentation suggests, a project is created with the npm create
command:
npm create umi
It seems to be working, but it's not documented.
Why did it appear and when? Is it a full synonym for npm init
? Is there a reason why npm create
should or should not be used?
Upvotes: 98
Views: 36236
Reputation: 31803
To answer this question, I ran:
npm create --help
which printed:
npm init [--force|-f|--yes|-y|--scope]
npm init <@scope> (same as `npx <@scope>/create`)
npm init [<@scope>/]<name> (same as `npx [<@scope>/]create-<name>`)
aliases: create, innit
So yes, it is a synonym, or more specifically an alias, for npm init
.
This was done using npm 6.10.1.
It doesn't matter which command one uses, but init
is the canonical form while create
is an alias. This is evidenced by the fact that npm create --help
actually invokes npm init --help
which is why we see create
listed as an alias in this above output.
Upvotes: 110
Reputation: 63802
The actual command is npm init
and npm create
is an alias, though npm create
seems to be more common in project documentation and in some sense more descriptive. You can read the documentation here on the npm github here.
npm create xyz
(or npm init xyz
) is a shorthand for running:
npx create-xyz
In other words, it prepends "create-" to the package name, temporarily installs that package, and then runs the script defined in the package.json
. This is used by several projects. For the umi
project, it implies there is a create-umi
package as well, and as you can see there is:
This is what the command is downloading and executing. Specifically it is executing the script defined in its package.json file:
"bin": {
"create-umi": "bin/create-umi.js"
},
Many frameworks follow this pattern so you can use the command. Some others:
Upvotes: 51
Reputation: 73
npm create is a shorter way to use a tool that sets up a new project quickly. e.g: npm create umi creates a new project using the umi framework for building web applications. It saves time by generating a basic project structure and installing any necessary dependencies.
While npm init creates a new package.json file for a project, it does not generate a basic project structure. npm create is a user-friendly alternative that automates the process of setting up a new project. npm create is a useful shortcut for setting up a new project quickly, but it's important to note that not all Node.js packages support it. like : express
Upvotes: 1