Node.js Core Modules for React Native

1.2.1 · abandoned · verified Tue Apr 21

This package, `node-libs-react-native`, provides React Native compatible implementations of various Node.js core modules such as `stream`, `http`, `buffer`, and `process`. It serves as a fork of `node-libs-browser`, specifically adapted for the React Native environment by swapping certain underlying packages for better mobile compatibility. The primary mechanism involves exposing a mapping of Node module names to their absolute React Native compatible file paths. This mapping is then leveraged within React Native Packager's `metro.config.js` resolver or Webpack's `resolve.alias` configuration to correctly resolve module imports within a React Native project. Additionally, it offers a dedicated `globals` module designed to shim Node.js specific global variables like `Buffer` and `process` into the React Native runtime. The current stable version, 1.2.1, was last published over five years ago, indicating that the project is likely abandoned. Given the rapid evolution of both Node.js and React Native, its utility in modern projects is limited, and more actively maintained alternatives or specific polyfills are generally recommended.

Common errors

Warnings

Install

Imports

Quickstart

Configures the Metro bundler resolver to provide React Native compatible Node.js core modules.

// metro.config.js
module.exports = {
  resolver: {
    // This configuration instructs Metro to resolve Node.js core modules
    // using the React Native compatible implementations provided by the package.
    extraNodeModules: require('node-libs-react-native'),
  },
  // It's also common to need a custom assetExts array
  // if you're importing assets not natively supported by React Native,
  // though not directly related to node-libs-react-native.
  // transformer: {
  //   getTransformOptions: async () => ({
  //     transform: {
  //       experimentalImportSupport: false,
  //       inlineRequires: true,
  //     },
  //   }),
  // },
};

view raw JSON →