---
title: "How to use NPM packages outside of Node"
url: https://daily.dev/posts/how-to-use-npm-packages-outside-of-node-mlvc2fg42
source_url: https://neon.com/blog/using-npm-packages-outside-node
type: article
source: "Neon"
published: 2026-07-09T06:57:43.638Z
updated: 2026-07-09T07:03:55.049Z
tags: ["webdev", "javascript", "nodejs", "serverless", "npm"]
reading_time: 7
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to use NPM packages outside of Node

**[Neon](https://daily.dev/sources/neontech)** · 7 min read · 0 upvotes · 0 comments

## Summary

Many npm packages rely on Node.js-specific features like Buffer, fs, or net.Socket, making them unusable in environments like Vercel Edge Functions, Cloudflare Workers, or browsers. Using esbuild as a bundler, several techniques can solve this: installing third-party shim packages for imported or global objects, using esbuild's --inject flag to polyfill globals like Buffer, creating stub packages for non-critical Node built-ins like fs, reimplementing simple Node APIs using Web APIs (e.g., TextDecoder for StringDecoder), and package masquerading to swap one package for another in a dependency tree. These approaches are illustrated with real examples from building the @neondatabase/serverless Postgres driver, which adapts the node-postgres pg package for serverless environments.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://neon.com/blog/using-npm-packages-outside-node>

## Similar posts on daily.dev

- [Optimizing JavaScript for the Edge Runtime](https://daily.dev/posts/optimizing-javascript-for-the-edge-runtime-kml5iehsg) · Telerik · 0 upvotes · 0 comments
- [Managing node\_modules efficiently with pnpm and Bun](https://daily.dev/posts/managing-node-modules-efficiently-with-pnpm-and-bun-26xxdqcfc) · Flavio Copes · 0 upvotes · 0 comments
- [JavaScript still can’t ship a full-stack module](https://daily.dev/posts/javascript-still-can-t-ship-a-full-stack-module-agbcwkmga) · ITNEXT · 2 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#javascript](https://daily.dev/tags/javascript), [#nodejs](https://daily.dev/tags/nodejs), [#serverless](https://daily.dev/tags/serverless), [#npm](https://daily.dev/tags/npm)

[View this post on daily.dev](https://daily.dev/posts/how-to-use-npm-packages-outside-of-node-mlvc2fg42)
