New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ores

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ores

Module resolution utilities based on Node.js upstream implementation.

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
0
Created
Source

ores

npm version npm downloads

Module resolution utilities for Node.js (based on previous work in unjs/mlly, wooorm/import-meta-resolve, and the upstream Node.js implementation).

This library exposes an API similar to import.meta.resolve based on Node.js upstream implementation and resolution algorithm. It supports all built-in functionalities—package.json, import maps, export maps, CJS, and ESM—with some additions:

  • Pure JS with no native dependencies (only Node.js is required).
  • Stable and versioned behavior.
  • Throws an error if the resolved path does not exist in the filesystem.
  • Can resolve from using one or more parent URLs.
  • Can override the default conditions.

Usage

Install package:

# ✨ Auto-detect (npm, yarn, pnpm, bun, deno)
npx nypm install ores

Import:

// ESM import
import { resolveModuleURL, resolveModulePath } from "ores";

// Or using dynamic import
const { resolveModuleURL, resolveModulePath } = await import("ores");
resolveModuleURL(id, {
  /* options */
});

resolveModulePath(id, {
  /* options */
});

Differences between resolveModuleURL and resolveModulePath:

  • resolveModuleURL returns a URL string like file:///app/dep.mjs.
  • resolveModulePath returns an absolute path like /app/dep.mjs.
    • If the resolved URL does not use the file:// scheme (for example, data: or node:), it will throw an error.

Resolve options

from

  • Default: (current working directory)

A URL, path or array of URLs/paths to resolve module against them.

extensions

  • Default [".mjs", ".cjs", ".js", ".json"]

Additional file extensions to consider when resolving modules.

conditions

  • Default: ["node", "import"]

Conditions to apply when resolving package exports.

Development

local development
  • Clone this repository
  • Install latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

License

Published under the MIT license.

Based on previous work in unjs/mlly, wooorm/import-meta-resolve and Node.js original implementation.

FAQs

Package last updated on 24 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts