deno.com

Import modules from npm

在 Github 上编辑

Use JavaScript modules from npm in your Deno programs with the "npm:" specifier in your imports.

Import the express module from npm using an npm: prefix, and appending a version number. Dependencies from npm can be configured in an import map also.
import express from "npm:express@4.18.2";
Create an express server
const app = express();
Configure a route that will process HTTP GET requests
app.get("/", (_req, res) => {
  res.send("Welcome to the Dinosaur API!");
});
Start an HTTP server using the configured Express app
app.listen(3000);

使用 Deno CLI 在本地运行 此示例

deno run --allow-net --allow-read --allow-env https://docs.denohub.com/examples/scripts/npm.ts

你找到需要的内容了吗?

隐私政策