Socket
Socket
Sign inDemoInstall

app-module-path

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

app-module-path

Simple module to add additional directories to the Node module search for top-level app modules


Version published
Weekly downloads
955K
decreased by-2.51%
Maintainers
3
Weekly downloads
 
Created

What is app-module-path?

The app-module-path npm package allows you to add directories to the Node.js module search path, making it easier to require modules without using relative paths.

What are app-module-path's main functionalities?

Add a single directory to the module search path

This feature allows you to add a single directory to the module search path. In this example, the 'lib' directory is added, making it possible to require modules from 'lib' without using relative paths.

const path = require('path');
require('app-module-path').addPath(path.join(__dirname, 'lib'));

Add multiple directories to the module search path

This feature allows you to add multiple directories to the module search path. In this example, both 'lib1' and 'lib2' directories are added, making it possible to require modules from either directory without using relative paths.

const path = require('path');
const appModulePath = require('app-module-path');
appModulePath.addPath(path.join(__dirname, 'lib1'));
appModulePath.addPath(path.join(__dirname, 'lib2'));

Add a directory to the module search path using environment variables

This feature allows you to add a directory to the module search path using environment variables. In this example, the 'lib' directory is added to NODE_PATH, and the module paths are re-initialized to include this directory.

process.env.NODE_PATH = path.join(__dirname, 'lib');
require('module').Module._initPaths();

Other packages similar to app-module-path

Keywords

FAQs

Package last updated on 05 Jan 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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc