npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

custom npm init command `npm init open-wc`

I see that there are some “custom” npm init commands like the one from stencil. It works as simple as running npm init stencil in your terminal. I would like to have the same ease of use but I just can’t figure out how it works or if it is documented somewhere?

the command I would like to create is npm init open-wc.

does anyone know how to archive this?


The init command is transformed to a corresponding npx operation as follows:

  • npm init foo -> npx create-foo
  • npm init @usr/foo -> npx @usr/create-foo
  • npm init @usr -> npx @usr/create

Any additional options will be passed directly to the command, so npm init foo --hello will map to npx create-foo --hello.

So for npm init open-wc you’d need to publish a package called create-open-wc which has a single binary file which initializes the (current) directory. You could also publish the package @open-wc/create (if you have access to that organization), and call it as npm init @open-wc. For an example you can look at init-package-json, the package that’s used for the plain npm init without any custom commands.

thaaankkkk you :slight_smile:

how could I have missed that :see_no_evil: