When running the Vite scaffolding command for a new Svelte project, I always wondered (but never gave much thought) about the use of the --
delimiter, but just assumed it was a type of chained or piped output:
npm create [email protected] PROJECT_NAME -- --template svelte
From a Stack Overflow answer, I learnt that:
--
as an argument on its own is standardized across all UNIX commands: It means that further arguments should be treated as positional arguments, not options.
As per the answer, this behavior is outlined in Guideline 10 of this documentation pertaining to POSIX Utility Syntax.
Further, according to Node’s documentation on CLI options:
--
Indicates the end of node options. Pass the rest of the arguments to the script. If no script filename or eval/print script is supplied prior to this, then the next argument will be used as a script filename.
In a nutshell, any syntax after the --
flag is read by the subcommand and has nothing to do with npm
itself, so in the case of Vite’s Svelte template, the --template
and svelte
options relate Vite entirely.
This is somewhat obvious, but what I learnt was why it’s necessary to pass Vite’s options after the --
option.
#TIL
#TheMoreYouKnow