Windows support coming soon!
Purpose
Require NPM is a lightweight library invented to download, cache, and reuse NPM modules.
It's intended for Require NPM to be used in both development and prototyping stages in order to eliminate redundant downloads of npm modules, with large codebases, while also improving developer productivity.
Require NPM allows you to reference npm modules and their dependencies throughout many projects without creating multiple redudant instances or ever requiring manual downloads.
### Installation
npm install require-npm --save-dev
OR
npm install -g require-npm-cli
Usage
Downloading and Configuring NPM Libraries
//requireNPM equals {decorate}//decorate instantiates {local, global, modules} within requireconst requireNPM = ; //check system cache, "npm install express", if hasn't been downloaded before with Require NPM.//no need to run "npm install express"!!const express = require app = ; //"hello world" express app;app
Using CLI (Comand Line Interface)
From your projects directory run:
require express
Then require express normally.
const express = ;
Simple Express App
const requireNPM = ;//binds methods ['global', 'local'] requireNPM; //downloads express codebase locally using npm, if they don't already exist, and then links to codebase within 'node_modules'.//no need to run "npm install express"!!const express = require app = ; app;app; { return require;}
Getting More Advanced With Our Express App
const requireNPM = ;//binds methods ['global', 'local']requireNPM; //downloads express codebase locally using npm, if they don't already exist, and then links to codebase within 'node_modules'.//no need to run "npm install express"!!const express = require app = port = 8080; app; { const listView = require ; thiscompiled = `<h1 style="font-family: sans-serif; font-weight: normal; padding: 8px 12px; border-radius: 2px; background: #336E7B; color: white;"> </h1> <ul></ul>`;} app;
Documentation
Require NPM (Main Module)
const requireNPM = require('require-npm');
The main module of requireNPM's main module is used to decorate the require function and retrieve information on directories and settings.
It consists of the following properties:
decorate: Function: decorate settings: Library: '/Users/<USER>/local-node-modules' LibraryModulePath: '/Users/<USER>/local-node-modules/node_modules' ProjectModulePath: '/Users/<USER>/projects/my cool app/node_modules'
requireNPM.decorate(obj)
requireNPM.decorate(require);
The decorate function is used to transfer the 'local', 'global', and 'modules' functions to an object. It is recommended that you use this decorator to transfer these functions to Node.js's require function.
It can also be used as follows.
const blank = {};requireNPM; blank;blank;blank;
require.local(...modules)
const express = require.local('express');
require.local downloads and caches any npm module requested. This allows you to reuse that npm module and it's dependencies, throughout all your projects, without redownloading any files.