Install.js is a minimal JavaScript module loader designed primarily to deliver CommonJS modules to web browsers, addressing the challenge of synchronous `require` semantics in a browser environment. While it provides a feature-rich, small-footprint solution for its original purpose, its development has been inactive since its last update in 2018 (version 0.13.0). The package offers explicit control over module installation and resolution, including options for file extensions, package.json `mainFields`, and a `fallback` mechanism for unresolved modules. It was created in an era before modern bundlers (like Webpack, Rollup) and native ECMAScript Modules (ESM) became standard practice, making its direct use in new projects less common today.
npm install installVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the `install` module loader, define and install custom CommonJS modules, and then `require` them using the loader's context. It shows the three main steps: `makeInstaller`, `install`, and `require`.
For new projects, consider modern bundlers for CommonJS/ESM compatibility or use native ESM. For legacy CommonJS in browsers, evaluate if a bundler could simplify the build process.
Always assign the result of `install()` to a locally scoped variable (e.g., `const myRequire = install(...)`) to avoid conflicts with Node.js's native module system.
Assess the necessity of this package. If possible, migrate to actively maintained alternatives or modern bundling solutions that are compatible with CommonJS for long-term project health.
Ensure `install.js` (or a bundled version) is correctly loaded in your HTML, and that `makeInstaller` and the subsequent `install` calls have been executed to create the `require` function for your modules.
Verify the module identifier path is correct relative to the calling module. Ensure the module is present in the object tree passed to `install`. Check `makeInstaller` options, especially `extensions` for implicit file endings and `mainFields` for `package.json` resolution.
This package is designed for CommonJS. If you are in an ESM context, you would typically use a bundler (like Webpack) that understands both CJS and ESM to integrate modules handled by `install`. If sticking to `install`, use `require()` within its defined module contexts.
No dependency data recorded yet.