Natural Pacifist Manatees
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

slash-node-modules-loader

1.0.3 • Public • Published

Slash Node Modules Loader

This module rewrites paths during require() so that if it sees a prefix of '/node_modules/' it is removed.

Example usage:

node -r slash-node-modules-loader ./index.js
// in index.js
 
const path = require('/node_modules/path');
const express = require('/node_modules/express');
const request = require('express');

It also works with esm for ES Modules.

node -r esm -r slash-node-modules-loader ./index.js
// in index.js
 
import HTMLElementPlus from '/node_modules/HTMLElementPlus';

The purpose of this is to allow ES Modules to be used isomorphicly by exposing '/node_modules/' as a route on the server. So any packages from npm can be used on the client and server without needing to use proxy modules.

Keywords

install

npm i slash-node-modules-loader

Downloadsweekly downloads

273

version

1.0.3

license

ISC

last publish

collaborators

  • avatar