0
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 7以上でViteを使用する際の--オプションの必要性

Posted at

はじめに

プログラミング学習中の@kat_logと申します。

viteでプロジェクトを作成する時にnpm create vite@latest project-name -- --template react-swc
というふうにコマンドを使用していたのですが、途中の--は要るのかどうなのか気になった際の知識のご共有です

結論:要る

要りました

--無しで(npm create vite@latest project-name --template react-swc)実行すると、
後半で指定している--template react-swcが適用されません

reactを指定しているのですが、どのフレームワークを使いますかなど聞かれちゃいます↓

image.png

どうして?

npm create vite@latest FilterableProductTable --template react-swc
の場合、--template react-swc オプションが Vite に正しく渡されず、npm 自身がこれを引数として解釈しようとするためみたいです。

npmのバージョンが7以上だと--必要

Vite公式ドキュメントに載っていました!

npm 7+, extra double-dash is needed

とのことです!

# npm 7+, extra double-dash is needed:
$ npm create vite@latest my-vue-app -- --template vue

結論 正しいコマンド↓

最初に記述した通り、
npm create vite@latest FilterableProductTable -- --template react-swc
が正解となります

ちなみに

こちらChatGPT o1 miniが正しく教えてくれました!
4o miniは間違えていました…!(--要らないと言われました)

image.png

おわりに

お読みいただきありがとうございました。
どなたかの参考になれば嬉しいです。

参考

0
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
0
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?