Big update!Announcing Socket for GitHub 1.0. Learn more
Socket
BlogLoveFAQ
Install
Log in

resolve-from

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Issues
File Explorer

Advanced tools

resolve-from

Resolve the path of a module like `require.resolve()` but from a given path

    5.0.0latest

Version published
Maintainers
1
Weekly downloads
61,536,077
decreased by-3.44%

Weekly downloads

Changelog

Source

Breaking:

  • Require Node.js 8 (#12) 188ed7d
  • Return undefined instead of null when the module cannot be found (#12) 188ed7d

Enhancements:

  • Add TypeScript definition (#12) 188ed7d

https://github.com/sindresorhus/resolve-from/compare/v4.0.0...v5.0.0

Readme

Source

resolve-from Build Status

Resolve the path of a module like require.resolve() but from a given path

Install

$ npm install resolve-from

Usage

const resolveFrom = require('resolve-from'); // There is a file at `./foo/bar.js` resolveFrom('foo', './bar'); //=> '/Users/sindresorhus/dev/test/foo/bar.js'

API

resolveFrom(fromDirectory, moduleId)

Like require(), throws when the module can't be found.

resolveFrom.silent(fromDirectory, moduleId)

Returns undefined instead of throwing when the module can't be found.

fromDirectory

Type: string

Directory to resolve from.

moduleId

Type: string

What you would use in require().

Tip

Create a partial using a bound function if you want to resolve from the same fromDirectory multiple times:

const resolveFromFoo = resolveFrom.bind(null, 'foo'); resolveFromFoo('./bar'); resolveFromFoo('./baz');
  • resolve-cwd - Resolve the path of a module from the current working directory
  • import-from - Import a module from a given path
  • import-cwd - Import a module from the current working directory
  • resolve-pkg - Resolve the path of a package regardless of it having an entry point
  • import-lazy - Import a module lazily
  • resolve-global - Resolve the path of a globally installed module

License

MIT © Sindre Sorhus

Keywords

FAQs

What is resolve-from?

Resolve the path of a module like `require.resolve()` but from a given path

Is resolve-from popular?

The npm package resolve-from receives a total of 49,922,537 weekly downloads. As such, resolve-from popularity was classified as popular.

Is resolve-from well maintained?

We found that resolve-from demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.It has 1 open source maintainer collaborating on the project.

Last updated on 15 Apr 2019
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc