5.0.0 • Published 6 years ago

resolve-from v5.0.0

Weekly downloads
42,502,534
License
MIT
Repository
github
Last release
6 years ago

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');

Related

  • 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

import-freshresolve-cwd@istanbuljs/load-nyc-config@storybook/uistylelintrequire_optionalrequire-uncachedlernanpm-lifecyclenyc@lerna/create@lerna/project@commitlint/resolve-extendsfree-mincuc-gaf@megasaur/project@huyhpham/rn-linearchetype-librarycomponennentt@xverse/matrix-code-generatoreasy-select-rnvuedragdropuploadimagesreact-native-bluetooth2killi8n-react-native-fast-imagepipihome@teapotz/node-file-traceget-addonsnx-gatsby-builderreact-static-juroshrn-send-smsspecify-importsbabel-specify-imports@icanpm/api-master@arisageha/react-lazyload@arisageha/react-lazyload-fix@shipengine/ipaas-loadermaybe-prettier@oneplanetcrowd/developers@cashremit/cr-streamline-icons@kibalabs/react-static@almeidaa/ms@penumbra/cli@shipengine/integration-platform-loaderreact-native-template-rfbasecloud-archive-s3@calebharnell/graphql-markdownairscanairscan-examplereadytest-testcafebb-chatreact-native-esc-pos-sahaab@devupx/vercel-builder@borisovart/atol-kkt-module@frxf/frxfamos-vercel-builder2amos-vercel-builder3deneme323112@texttree/demo-bsa-reference-rcl@nexhome/cli@fundefund/funde_ck@finets/core@bravejs/bootstrapper@ntt_app/react-native-custom-notificationreact-native-custom-text-hwjames@educationperfect/semantic-release@foreman/dependantreact-native-covid-sdkeasycommands-betagql_din_modbitgetafryxiconsreact-native-thanh-toast-librarymutasi-bcarotareneg-ipacnysa@jttechnic/interpreter@thanhnguyen14797/react-native-thanh-toast-library@l1nyanm1ng/react-picture-viewer@eginnovations/eginnovations-capacitor-pluginvite-play@saeon/quick-formcthpb-plugin-social@iobroker-community-adapters/iobroker.device-watcher@olivervorasai/slidermysql-formatreact-native-printer-brothersrn-pdf-reader-offlinecbmis-ai-toolboxawesome-fonts@belko.tech/belko-multi-wallet-sdk@newhorizon-tech/dd-npm-package-templatereact-native-shekhar-bridge-testcogoportutilsukor-remasteruncoded-connect@reversodev/oceanic-fleetlevibestliblevibestlib2levilibtest19levilibtest24levilibtest25
5.0.0

6 years ago

4.0.0

7 years ago

3.0.0

8 years ago

2.0.0

9 years ago

1.0.1

9 years ago

1.0.0

10 years ago