New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

lrequire

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lrequire

A module which allows you to require and try out npm modules directly without `npm install`-ing them. You can use this to quickly test out different modules in your project, inside a toy project or in the terminal.

latest
npmnpm
Version
1.0.5
Version published
Weekly downloads
8
300%
Maintainers
1
Weekly downloads
 
Created
Source

Live-require

NPM Build Status dependencies Code Climate

A module which allows you to require and try out npm modules directly without npm install-ing them. You can use this to quickly test out different modules in your project, inside a toy project or in the terminal.

How it works

Modules are downloaded and prepared in a predefined directory(/tmp/ by default) and then required back to you. The modules are cached so only the first time a module is used it might take a little longer to load.

Configuration

const lrequire = require('lrequire');

lrequire.configure({
    path: '/tmp/lrequire' //where the modules will be downloaded
})

Programmatic Usage

Basic:

const lrequire = require('lrequire');

const validUrl = lrequire('valid-url');
const latestVersion = lrequire('npmjs.org/package/latest-version');

Download specific version:

const lrequire = require('lrequire');

const validUrl = lrequire('valid-url', {
    version: '1.0.8'
});
const latestVersion = lrequire('npmjs.org/package/latest-version', {
    version: 'latest' //this is the default
});

You can also make lrequire global and use it at will. Later, if you wish to keep a package, you can remove the l and everything will continue working.

require('lrequire').global();

const validUrl = lrequire('valid-url');
const latestVersion = lrequire('npmjs.org/package/latest-version');

Repl Usage

Make sure to install lrequire globally:

$ npm i -g lrequire

Execute lrequire in your terminal, the lrequire function will be available in the newly opened repl which means you can directly start requiring modules. You can also use the require function, it will try to require a module and fallback to lrequire.

$ lrequire
> const { markdown } = require('markdown');
> $ markdown.toHTML('Hello *World*!');
'<p>Hello <em>World</em>!</p>'

What if you don't want to create files in your filesystem?

On linux consider using tmpfs. You can mount it on /tmp/lrequire or even /tmp which is a common practice. Don't forget that the directory where the files are saved can be configured.

On MacOS and Windows there are some RamDisk implementations that might work.

Requirements

Node 8

API Reference

lrequire(module, config = {version: 'latest'})

Require a module synchronously.

lrequire.async(module, config = {version: 'latest'}): Promise<Module>

Require a module asynchronously, the result can be awaited.

lrequire.asyncCallback(module, config, callback)

Require a module asynchronously, the result is passed as a second argument as per the node.js callback conventions.

lrequire.config(config = {path: '/tmp/lrequire'})

Configure lrequire.

lrequire.global()

Add lrequire to global.

lrequire.config

Get the config object

lrequire.latestVersionCache

Get the cache which holds the latest version available in npm for each package installed during the application's lifetime.

FAQs

Package last updated on 07 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts