Skip to content
This repository has been archived by the owner on Sep 21, 2023. It is now read-only.

Latest commit

 

History

History
44 lines (34 loc) · 885 Bytes

package_json.md

File metadata and controls

44 lines (34 loc) · 885 Bytes

package.json compatibility

Deno supports resolving dependencies based on a package.json file in the current or ancestor directories. This is similar to how Node.js resolves dependencies. We recommend using import maps with deno.json which is explained here.

package.json

{
  "name": "@deno/my-example-project",
  "description": "An example app created with Deno",
  "type": "module",
  "scripts": {
    "dev": "deno run --allow-env --allow-sys main.ts"
  },
  "dependencies": {
    "chalk": "^5.2"
  }
}

main.ts

import chalk from "chalk";

console.log(chalk.green("Hello from Deno!"));

Then we can run this script:

> deno run --allow-env --allow-sys main.ts
Hello from Deno!

Or also execute package.json scripts via deno task:

> deno task dev
Hello from Deno!