|
| 1 | +--- |
| 2 | +title: "deno create, scaffold a new project" |
| 3 | +command: create |
| 4 | +openGraphLayout: "/open_graph/cli-commands.jsx" |
| 5 | +openGraphTitle: "deno create" |
| 6 | +description: "Scaffold a new project from a template package" |
| 7 | +--- |
| 8 | + |
| 9 | +The `deno create` command scaffolds a new project from a template package. It |
| 10 | +works with both [JSR](https://jsr.io/) and [npm](https://www.npmjs.com/) |
| 11 | +packages that provide project templates. |
| 12 | + |
| 13 | +## Usage |
| 14 | + |
| 15 | +```sh |
| 16 | +deno create [OPTIONS] [PACKAGE] [-- [ARGS]...] |
| 17 | +``` |
| 18 | + |
| 19 | +By default, unprefixed package names are resolved from JSR. You can use the |
| 20 | +`npm:` or `jsr:` prefix to be explicit, or use the `--npm` / `--jsr` flags. |
| 21 | + |
| 22 | +## How it works |
| 23 | + |
| 24 | +Package resolution differs between npm and JSR: |
| 25 | + |
| 26 | +- **npm packages** use the `create-` naming convention. Running |
| 27 | + `deno create npm:vite` resolves to the `create-vite` package on npm and |
| 28 | + executes its main entry point. |
| 29 | +- **JSR packages** use the `./create` export. Any JSR package can act as a |
| 30 | + template by defining a `./create` entry point in its `deno.json`: |
| 31 | + |
| 32 | +```json title="deno.json" |
| 33 | +{ |
| 34 | + "name": "@my-scope/my-template", |
| 35 | + "version": "1.0.0", |
| 36 | + "exports": { |
| 37 | + ".": "./mod.ts", |
| 38 | + "./create": "./create.ts" |
| 39 | + } |
| 40 | +} |
| 41 | +``` |
| 42 | + |
| 43 | +When you run `deno create @my-scope/my-template`, Deno looks for the `./create` |
| 44 | +export and runs it as the scaffolding script. |
| 45 | + |
| 46 | +## Examples |
| 47 | + |
| 48 | +Create a project from a JSR package: |
| 49 | + |
| 50 | +```sh |
| 51 | +deno create @fresh/init |
| 52 | +``` |
| 53 | + |
| 54 | +Create a project from an npm package: |
| 55 | + |
| 56 | +```sh |
| 57 | +deno create npm:vite my-app |
| 58 | +``` |
| 59 | + |
| 60 | +Using the `--npm` flag to treat unprefixed names as npm packages: |
| 61 | + |
| 62 | +```sh |
| 63 | +deno create --npm create-vite my-app |
| 64 | +``` |
| 65 | + |
| 66 | +Pass arguments to the template package: |
| 67 | + |
| 68 | +```sh |
| 69 | +deno create @fresh/init -- --force |
| 70 | +``` |
| 71 | + |
| 72 | +## Flags |
| 73 | + |
| 74 | +- `--npm` - Treat unprefixed package names as npm packages |
| 75 | +- `--jsr` - Treat unprefixed package names as JSR packages (default) |
| 76 | +- `-y, --yes` - Bypass the prompt and run with full permissions |
0 commit comments