Skip to content

Conversation

@thisisjofrank
Copy link
Collaborator

@thisisjofrank thisisjofrank commented Oct 24, 2025

Updating as per @littledivy's feedback in #2684

  • Added: Quick start

  • Added: First-class package.json support

  • Reordered: Node.js global objects earlier

  • Simplified: CommonJS intro and troubleshooting

  • Added: .cjs run example (deno run -A main.cjs)

  • Added: node_modules mode decision guide

  • Removed: npx analogy snippet

  • Renamed: Deno 1.X-specific node_modules subsection

  • Compressed: Migrating and Optional improvements

  • Content refocused on tasks and outcomes

  • Duplicates removed and legacy bits trimmed

  • Headings and structure tightened

@littledivy please feel free to edit/remove details as you see fit!

@thisisjofrank thisisjofrank marked this pull request as ready for review October 24, 2025 11:55
Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! A quick start section is nice

Comment on lines +37 to +40
### Import an npm package

```ts title="main.ts"
import chalk from "npm:chalk@5";
Copy link
Member

@bartlomieju bartlomieju Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I honestly feel we should limit number of examples using npm: specifiers in the docs website and should prefer deno install npm:chalk and then import chalk from "chalk"; so it's as familiar as possible to people coming from Node

Comment on lines +51 to +53
// CommonJS works out of the box
module.exports = { ok: true };
console.log("CJS runs in Deno");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// CommonJS works out of the box
module.exports = { ok: true };
console.log("CJS runs in Deno");
const chalk = require("chalk");
console.log(chalk.green("Hello from npm in Deno"));

deno run main.ts
```

### Run a .cjs file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Run a .cjs file
### Execute CommonJS


### Run a .cjs file

```js title="main.cjs"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```js title="main.cjs"
Use `.cjs` extension to inform Deno that module is using CommonJS system.
```js title="main.cjs"

Comment on lines +62 to +68
```js title="process.mjs"
import process from "node:process";
console.log(process.platform);
```

```sh
deno run process.mjs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```js title="process.mjs"
import process from "node:process";
console.log(process.platform);
```
```sh
deno run process.mjs
```js title="process.js"
import path from "node:path";
console.log(path.join("./foo", "../bar"));
deno run process.js

(.mjs is not important and process is widely available as a global)

Comment on lines +142 to +143
using `nodeModulesDir` in `deno.json` or the `--node-modules-dir` flag (see the
node_modules section below).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using `nodeModulesDir` in `deno.json` or the `--node-modules-dir` flag (see the
node_modules section below).
using `nodeModulesDir` in `deno.json`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants