1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

npm create は何をしているか

Posted at

はじめに

フロントエンドフレームワークのドキュメントの中で登場するnpm create
どのような仕組みで動作しているか調べてみました。

本記事内ではAstroを例として挙げています
https://astro.build/

npm createの挙動

以下はhelpでnpm initを確認したものだ。
こちらを確認すると、npm createnpm initのエイリアスということがわかる。

❯ npm init --help
Create a package.json file

Usage:
npm init <package-spec> (same as `npx <package-spec>`)
npm init <@scope> (same as `npx <@scope>/create`)

Options:
[--init-author-name <name>] [--init-author-url <url>] [--init-license <license>]
[--init-module <module>] [--init-version <version>] [-y|--yes] [-f|--force]
[--scope <@scope>]
[-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
[-ws|--workspaces] [--no-workspaces-update] [--include-workspace-root]

aliases: create, innit

Run "npm help init" for more info

詳細は以下ドキュメントで確認可能。

ドキュメントで確認すると、npm initは以下のようにnpm execに変換されるようだ。
npm init foo->npm exec create-foo

そのため、以下3つのコマンドの実行結果は同じとなる。

❯ npm create astro@latest
Need to install the following packages:
create-astro@4.10.0
Ok to proceed? (y)

❯ npm init astro@latest 
Need to install the following packages:
create-astro@4.10.0
Ok to proceed? (y)

❯ npm exec create-astro@latest
Need to install the following packages:
create-astro@4.10.0
Ok to proceed? (y)

結論

npm create astro@latestを実行すると内部ではnpm exec create-astro@latestが実行される。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?