{"library":"meteor-node-stubs","title":"Meteor Node Stubs","description":"meteor-node-stubs provides browser-compatible stub implementations for Node.js built-in modules (e.g., `path`, `buffer`, `process`, `crypto`). It enables NPM packages, even those initially for Node.js, to run within Meteor client-side applications by transparently redirecting imports to these browser-friendly stubs, requiring no manual configuration. The current stable version is 1.2.27, with releases tied to the broader Meteor ecosystem's update cycle for security and compatibility, including Meteor 3.x. Its key differentiator is automatic integration with Meteor's build process, minimizing client bundle bloat by only including necessary stubs.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install meteor-node-stubs"],"cli":null},"imports":["import { join } from 'path';","console.log(process.env.NODE_ENV);","import { Buffer } from 'buffer';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { Meteor } from 'meteor/meteor';\nimport { basename, extname } from 'path'; // Importing Node.js 'path' module\n\nif (Meteor.isClient) {\n  Meteor.startup(() => {\n    // This code runs only on the client (browser)\n    const filePath = '/home/user/document.txt';\n    const baseName = basename(filePath);\n    const extension = extname(filePath);\n\n    console.log(`Original Path: ${filePath}`);\n    console.log(`Base Name: ${baseName}`);\n    console.log(`File Extension: ${extension}`);\n\n    // Demonstrate another common stub, 'process'\n    // process.env is stubbed for browser compatibility\n    console.log(`Environment (from stubbed process): ${process.env.NODE_ENV ?? 'development'}`);\n    console.log(`Is browser? (from stubbed process): ${process.browser ?? true}`);\n\n    // Example of a function that might not be fully stubbed or is a no-op\n    try {\n      // The 'fs' module is typically not fully implemented in browser stubs.\n      // Attempting to use server-side filesystem operations will fail.\n      // import * as fs from 'fs'; // If actually imported, would be at top\n      // fs.readFile('/some/file.txt', () => {}); \n      console.log(\"Attempted to use fs (may not work as expected in browser stubs).\");\n    } catch (e) {\n      console.warn(\"fs module is likely not fully implemented in browser stubs:\", e.message);\n    }\n  });\n}","lang":"javascript","description":"Demonstrates using Node.js built-in modules like `path` and `process` in client-side Meteor code, relying on `meteor-node-stubs` to provide browser-compatible implementations.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}