4.0.0 • Published 3 years ago

import-from v4.0.0

Weekly downloads
9,895,778
License
MIT
Repository
github
Last release
3 years ago

import-from

Import a module like with require() but from a given path

Install

$ npm install import-from

Usage

const importFrom = require('import-from');

// There is a file at `./foo/bar.js`

importFrom('foo', './bar');

API

importFrom(fromDirectory, moduleId)

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

importFrom.silent(fromDirectory, moduleId)

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

fromDirectory

Type: string

Directory to import from.

moduleId

Type: string

What you would use in require().

Tip

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

const importFromFoo = importFrom.bind(null, 'foo');

importFromFoo('./bar');
importFromFoo('./baz');

Related

  • import-cwd - Import a module from the current working directory
  • resolve-from - Resolve the path of a module from a given path
  • resolve-cwd - Resolve the path of 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 modules lazily
  • import-global - Import a globally installed module
import-cwd@graphql-codegen/plugin-helpersarchetype-libraryvuedragdropuploadimagesreact-native-bluetooth2killi8n-react-native-fast-imagea-xyj-test@penumbra/clicloud-archive-s3airscanairscan-examplebb-chatreact-native-esc-pos-sahaab@borisovart/atol-kkt-moduledeneme323112@fundefund/funde_ck@ntt_app/react-native-custom-notificationreact-native-covid-sdk@olivervorasai/sliderreact-native-printer-brotherscogoportutils@mink-opn/build-tokens@infinitebrahmanuniverse/nolb-imp@prodam/prodam-types@saaspe/componentsexpand-react-bridge@everything-registry/sub-chunk-1908p149-tabletest-popupsmedusa_valkelectronmonelectron-backgroundeslint-to-editorconfig@ojshua/electronmon@playlyfe/gql-language-server@sdr/cli@patternplate/cliwebpack-cyo-dashboardwebpack-clis-utilswebpack-cli-utilwebpack-jarviswebpack-jarvis-zhorigami-core-libomnisvitae@phpboyscout/scoped-release-notes-generator@phpboyscout/semantic-release-commit-analyzerwebql-tools-loadwebql-codegen-plugin-helperswebpack-reportp147-tablep148-tablenka-gantt-task-reactvformlmqvision-camera-plugin-scan-facesnpm_qwertyvue-button-test1npm_one_12_34_1_npm_one_1_2_3npm_one_2_2vue-compment@nut-project/dev-utilsmipha-climff-cliverify-img-codepayutesting@ramk-exp/commit-analyzer@southcn/ckeditor5-build-inlineplayer-dashboard@static-pages/cli@stansaal/ckeditor5-custom-build@saad27/react-native-bottom-tab-tour@sak1sham/react-toc-highlight@oriduk/ckeditor5-rebuild-musicanote@origami/core-lib@oriduk/ckeditor5-rebuild-oridukdoxdox-cli@pika/pack@robbertc/release-notes-generator-filteredprasadacm@superewaldo/release-notes-generatorwikic@skedulr/nebula-ui-library@skeetboothppq/component-library@skidding/react-cosmos-webpackng-search-dropdown@owngames/release-notes-generator@packetsafari/clivue-v3-yandex-metrikavue3-google-login-with-statetiztingzi-vuepressnative-google-loginnative-kakao-login@teamcodafication/commit-analyzer@ttionya/test@tuber/choc@simplej/rapid-clipasteljs@taingo97/react-native-expo-rsa@taingo97/react-native-rsa
4.0.0

3 years ago

3.0.0

5 years ago

2.1.0

7 years ago