Socket
Socket
Sign inDemoInstall

import-from

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0 to 4.0.0

9

index.js
'use strict';
const resolveFrom = require('resolve-from');
const path = require('path');
const {createRequire} = require('module');
module.exports = (fromDirectory, moduleId) => require(resolveFrom(fromDirectory, moduleId));
module.exports = (fromDirectory, moduleId) => createRequire(path.resolve(fromDirectory, 'noop.js'))(moduleId);
module.exports.silent = (fromDirectory, moduleId) => {
try {
return require(resolveFrom(fromDirectory, moduleId));
} catch (_) {}
return createRequire(path.resolve(fromDirectory, 'noop.js'))(moduleId);
} catch {}
};
{
"name": "import-from",
"version": "3.0.0",
"version": "4.0.0",
"description": "Import a module like with `require()` but from a given path",
"license": "MIT",
"repository": "sindresorhus/import-from",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"engines": {
"node": ">=8"
"node": ">=12.2"
},

@@ -32,5 +33,2 @@ "scripts": {

],
"dependencies": {
"resolve-from": "^5.0.0"
},
"devDependencies": {

@@ -37,0 +35,0 @@ "ava": "^1.4.1",

@@ -1,6 +0,5 @@

# import-from [![Build Status](https://travis-ci.org/sindresorhus/import-from.svg?branch=master)](https://travis-ci.org/sindresorhus/import-from)
# import-from
> Import a module like with [`require()`](https://nodejs.org/api/modules.html#modules_require_id) but from a given path
## Install

@@ -12,3 +11,2 @@

## Usage

@@ -24,3 +22,2 @@

## API

@@ -48,3 +45,2 @@

## Tip

@@ -61,3 +57,2 @@

## Related

@@ -71,6 +66,1 @@

- [import-global](https://github.com/sindresorhus/import-global) - Import a globally installed module
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc