5.0.0 • Published 2 years ago

resolve-from v5.0.0

Weekly downloads
42,502,534
License
MIT
Repository
github
Last release
2 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-cwdimport-from@istanbuljs/load-nyc-config@storybook/themingstylelint@storybook/uirequire-uncachedrequire_optional@lerna/projectnyc@commitlint/loadnpm-lifecycle@commitlint/resolve-extendsreact-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-loaderbabel-preset-slickmaybe-prettier@oneplanetcrowd/developers@cashremit/cr-streamline-icons@kibalabs/react-static@almeidaa/mssimple-axios@penumbra/cli@shipengine/integration-platform-loaderreact-native-template-rfbasecloud-archive-s3@calebharnell/graphql-markdownairscanairscan-exampleprisma-fixtures-clireadytest-testcafebb-chatreact-native-esc-pos-sahaab@devupx/vercel-builder@borisovart/atol-kkt-module@frxf/frxf@mastermonar/fusion-cli@tscc/tscc@dtinth/nuxtjs__vercel-builderupappvue-nycvue-compilevue-compment@goraxe/semantic-releasesemantic-release-plussemantic-release-ramkraosemantic-release-tsheets-testsemantic-release-wo-notessemantic-release-flexsemver-inc-wizardserverless-plugin-optimize@finets/corevcloudcam-playkit-js-hls@fazal/ckeditor5-custom-buildroc-plugin-reporhcp-clirod-testcafe@homerjam/now-builderwebql-tools-import@huygn/react-staticweigh@ianwang/babel-plugin-inline-react-svg@ianwang/babel-plugin-react-inline-svg@huzan/hz-umi-plugin-patch@foreman/dependant@flemist/require-css@flaviut/parcel-plugin-typescript@flybondi/graphql-importxdlwebpackerator@jretts/modified-sveltejsxo@joakimbeng/react-native-versionxle-bot@journeyapps/terntemp-semantic-release-debugtestnpm_lmnterntern-jsxtestyantratextfield-sample@dgsh/processusternjs@enjoylife/fusion-cli@eginnovations/eginnovations-capacitor-plugin@erquhart/lerna-project@eluck/mup
5.0.0

2 years ago

4.0.0

3 years ago

3.0.0

4 years ago

2.0.0

5 years ago

1.0.1

5 years ago

1.0.0

7 years ago