Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inDemoInstall

import-from

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Issues
File Explorer

Advanced tools

import-from

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

    4.0.0latest
    Github

Version published
Maintainers
1
Weekly downloads
10,246,174
increased by5.59%

Weekly downloads

Readme

Source

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

Keywords

FAQs

What is import-from?

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

Is import-from popular?

The npm package import-from receives a total of 9,830,748 weekly downloads. As such, import-from popularity was classified as popular.

Is import-from well maintained?

We found that import-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 01 Jun 2021

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket[email protected]

Product

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc