Node.js built-in modules provide ready-to-use features like file handling, networking, and streams without needing extra installation.
Click to reveal answer
intermediate
How does Deno support Node.js built-in modules?
Deno supports many Node.js built-in modules by providing compatibility layers or polyfills, allowing code using Node.js modules to run in Deno.
Click to reveal answer
intermediate
Show how to import the 'fs' module in Node.js and its equivalent in Deno.
In Node.js: <code>import fs from 'fs';</code><br>In Deno: <code>import * as fs from 'node:fs';</code> or use Deno's native <code>Deno.readFile</code> APIs.
Click to reveal answer
advanced
Why might some Node.js built-in modules not work perfectly in Deno?
Because Deno has different security, APIs, and runtime design, some Node.js modules may lack full support or behave differently.
Click to reveal answer
beginner
What command enables Node.js compatibility in Deno?
Running Deno with the --unstable flag enables Node.js compatibility mode.
Click to reveal answer
Which flag enables Node.js compatibility in Deno?
A--polyfill
B--unstable
C--legacy
D--node
✗ Incorrect
The --unstable flag enables Node.js compatibility mode in Deno.
How do you import the 'path' module from Node.js in Deno?
Aimport path from 'path';
Bimport path from 'deno:path';
Cimport * as path from 'node:path';
Dimport * as path from 'fs:path';
✗ Incorrect
Deno uses the node: prefix to import Node.js built-in modules, so import * as path from 'node:path'; is correct.
Why might some Node.js modules not work fully in Deno?
ADeno has different security and runtime design.
BDeno does not support JavaScript.
CNode.js modules are written in Python.
DDeno only supports browser APIs.
✗ Incorrect
Deno's different security model and runtime design can cause some Node.js modules to not work fully.
Which of these is NOT a Node.js built-in module?
Aexpress
Bhttp
Cfs
Dpath
✗ Incorrect
express is a third-party library, not a built-in module.
What is a benefit of using Node.js built-in modules?
AThey are only for frontend development.
BThey slow down your app.
CThey are written in CSS.
DThey require no installation and are ready to use.
✗ Incorrect
Built-in modules come with Node.js and need no extra installation.
Explain how Deno supports Node.js built-in modules and what flags are needed to enable this support.
Think about how Deno runs Node.js code and what command line options help.
You got /4 concepts.
Describe the difference between importing a Node.js built-in module in Node.js versus in Deno.
Focus on how the import statement changes.
You got /4 concepts.
Practice
(1/5)
1. What is the correct way to import the Node.js built-in path module in Deno?