You don't need Node to use NPM packages

Beyond Fireship · Beginner ·🌐 Frontend Engineering ·3y ago

Key Takeaways

The video demonstrates how to use Node.js packages in the Deno JavaScript runtime with its new NPM specifier, allowing for the use of packages like Express.js without the need for Node.js.

Full Transcript

when Dino came out it blew people's minds and they called it the node killer thanks to its out of the box typescript support and URL based package manager it Embraces es modules and other web standard apis but that's a bit of a problem because it means you can't use all your favorite npm packages in Dino then out of nowhere bun came along another high performance JavaScript runtime with out of the box typescript but also support for all your favorite npm packages they called it the dino killer but this dinosaur would not go extinct without a fight and just a few weeks ago Dino announced support for npm which is a huge deal because I think that was the main deal breaker for people not using Dino in the first place let's check it out to see if it's any good first make sure you have version 1.28 installed or later and if not run Dino upgrade from there create a main.ts file and make sure you have the dino vs code extension installed and then go to the command palette and initialize the workspace now let's imagine we want to use a node package like express.js we can do that by importing it just like a regular yes module but prefixed with this npm specifier and you can also optionally specify by a version number here as well what's cool about this is that there is no npm install required no package Json file and no node modules folder it's way cleaner let's now go ahead and build a basic Express API that has a git endpoint and listens to the port of your choice now let's go ahead and run it with the Dino Run command the first time it runs you'll notice how it downloads the dependencies in the background this might take a while on the first run but it'll be cached for future use now before the code actually executes it will prompt you to allow a bunch of different permissions which prevents Shady packages from doing things they're not supposed to like mine Dogecoin in the background we know Express is legit so we can use the allow all flag to bypass this process and now we're running Express in Dino that's pretty cool but there is one problem Express is written in pure JavaScript and Dino doesn't have access to its typescript types which means we don't get any intellisense in the IDE we can fix that by adding this Dino types directive to the top that points to the type definitions for Express and now we get this beautiful intellisense keep in mind though this step is only required for packages that don't ship their own type type definitions now the other cool thing about Dino and npm is that we can also run commands like those you would run with npx normally a few months ago I built a CLI with node which you can run with npx fire quiz now we can also run it on Dino with Dino Run npm colon fire quiz this is huge because it means we can run virtually any CLI tool like Veet from Dino without ever having to touch node.js itself now while it's definitely awesome to have npm support here there are some caveats like it doesn't currently work with the compile command which you'd want to use to create a self-contained executable for other Platforms in addition there are many npm packages out there that may not be compatible as a result of node's non-standard module system but then again we are still in JavaScript world where you should never expect anything to work exactly as promised thanks for watching and I will see you in the next one

Original Description

Learn how to use Node.js packages in the Deno JavaScript runtime with its new NPM specifier. #typescript #nodejs #javascript Deno NPM support blog post https://deno.com/blog/v1.28 Fireship CLI Tutorial https://youtu.be/_oHByo8tiEY
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Beyond Fireship · Beyond Fireship · 20 of 42

1 Social Media Style Number Formatting in JS
Social Media Style Number Formatting in JS
Beyond Fireship
2 I used 3 different File System APIs in Node.js
I used 3 different File System APIs in Node.js
Beyond Fireship
3 Time is Relative, even in JavaScript
Time is Relative, even in JavaScript
Beyond Fireship
4 How to NOT Screw Up Firebase Environment Variables
How to NOT Screw Up Firebase Environment Variables
Beyond Fireship
5 How to make your JavaScript Bundle Smaller
How to make your JavaScript Bundle Smaller
Beyond Fireship
6 Subtle, yet Beautiful Scroll Animations
Subtle, yet Beautiful Scroll Animations
Beyond Fireship
7 Beyond Surreal? A closer look at NewSQL Relational Data
Beyond Surreal? A closer look at NewSQL Relational Data
Beyond Fireship
8 How to Build a Discord Bot
How to Build a Discord Bot
Beyond Fireship
9 How to make Eyeballs that Follow You Around
How to make Eyeballs that Follow You Around
Beyond Fireship
10 Reverse Engineer Google’s NASA Dart Easter Egg with CSS
Reverse Engineer Google’s NASA Dart Easter Egg with CSS
Beyond Fireship
11 Generate Images Programmatically on the Edge
Generate Images Programmatically on the Edge
Beyond Fireship
12 WTF are all these config files for?
WTF are all these config files for?
Beyond Fireship
13 NEW Firebase Features Just Dropped
NEW Firebase Features Just Dropped
Beyond Fireship
14 Next.js 13 - The Basics
Next.js 13 - The Basics
Beyond Fireship
15 Make Crazy Art with the NEW OpenAI Dall-e API
Make Crazy Art with the NEW OpenAI Dall-e API
Beyond Fireship
16 How to Setup Node.js with TypeScript in 2023
How to Setup Node.js with TypeScript in 2023
Beyond Fireship
17 Dramatically improve website speed with Partytown
Dramatically improve website speed with Partytown
Beyond Fireship
18 The easiest realtime app I’ve ever built
The easiest realtime app I’ve ever built
Beyond Fireship
19 10 Rendering Patterns for Web Apps
10 Rendering Patterns for Web Apps
Beyond Fireship
You don't need Node to use NPM packages
You don't need Node to use NPM packages
Beyond Fireship
21 Sorting Algorithms Explained Visually
Sorting Algorithms Explained Visually
Beyond Fireship
22 ChatGPT Official API First Look
ChatGPT Official API First Look
Beyond Fireship
23 I built an image search engine
I built an image search engine
Beyond Fireship
24 Industrial-scale Web Scraping with AI & Proxy Networks
Industrial-scale Web Scraping with AI & Proxy Networks
Beyond Fireship
25 Next.js Server Actions...  5 awesome things you can do
Next.js Server Actions... 5 awesome things you can do
Beyond Fireship
26 The ultimate guide to web performance
The ultimate guide to web performance
Beyond Fireship
27 I built a fullstack PaLM AI app in just 2 minutes
I built a fullstack PaLM AI app in just 2 minutes
Beyond Fireship
28 I tried 8 different Postgres ORMs
I tried 8 different Postgres ORMs
Fireship
29 I built a *streaming* AI chat app
I built a *streaming* AI chat app
Fireship
30 React VS Svelte...10 Examples
React VS Svelte...10 Examples
Fireship
31 How GitHub Actions 10x my productivity
How GitHub Actions 10x my productivity
Fireship
32 PROOF JavaScript is a Multi-Threaded language
PROOF JavaScript is a Multi-Threaded language
Fireship
33 Mind-blowing page animations are easy now... View Transitions API first look
Mind-blowing page animations are easy now... View Transitions API first look
Fireship
34 I built an Apple Vision Pro app... visionOS tutorial
I built an Apple Vision Pro app... visionOS tutorial
Fireship
35 This UI component library is mind-blowing
This UI component library is mind-blowing
Fireship
36 How I deploy serverless containers for free
How I deploy serverless containers for free
Fireship
37 GitHub Copilot now controls your command line...
GitHub Copilot now controls your command line...
Fireship
38 Build better payment forms using new “embedded” Stripe Checkout
Build better payment forms using new “embedded” Stripe Checkout
Fireship
39 Does Deno 2 really uncomplicate JavaScript?
Does Deno 2 really uncomplicate JavaScript?
Fireship
40 JavaScript performance is weird... Write scientifically faster code with benchmarking
JavaScript performance is weird... Write scientifically faster code with benchmarking
Fireship
41 Is Next.js 15 any good? "use cache" API first look
Is Next.js 15 any good? "use cache" API first look
Beyond Fireship
42 I built a DeepSeek R1 powered VS Code extension…
I built a DeepSeek R1 powered VS Code extension…
Fireship

Learn how to use Node.js packages in Deno with the new NPM specifier, and how to run CLI tools like Express.js without needing Node.js. This allows for a more streamlined development process and access to a wide range of packages.

Key Takeaways
  1. Install Deno version 1.28 or later
  2. Create a main.ts file
  3. Initialize the Deno workspace
  4. Import Node.js packages using the npm specifier
  5. Build a basic Express API
  6. Run the API with Deno Run
  7. Allow permissions for dependencies
  8. Add type definitions for packages that don't ship with them
💡 Deno's new NPM specifier allows for the use of Node.js packages without the need for Node.js, making it a more viable option for developers who want to use TypeScript and web standard APIs.

Related AI Lessons

Up next
The masks we wear | Zora Krstić | TEDxLuxembourgCity
TEDx Talks
Watch →