New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

packpath

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

packpath

Find the path(s) package.json.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.9K
decreased by-22.59%
Maintainers
1
Weekly downloads
 
Created
Source

Node.js - packpath

packpath helps you to find directories that contain package.json.

Why?

The directory with package.json is considered a module's base or root directory. At times, it's extremely convenient to need to know where that is.

Let's say that you write a module and you hate having to require() your files using relative paths ../../, etc. This is how the module autoresolve works. Or, let's say that you are writing a module that needs to access configuration files in an app that called require on your module. These paths can get hairy fast.

Installation

npm install packpath

Usage

For your apps, assuming you want to access your own config files, etc.

app.js:

var packpath = require('packpath');

//<-- your own confile dir
var configDir = path.join(packpath.self(), 'config');

For your modules, assuming you want to access developers' config files who "required" your module.

mywidget.js:

var packpath = require('packpath');

//the config dir of the app that called your module through require()
var configDir = path.join(packpath.parent(), 'config'); 

License

(MIT License)

Copyright 2012, JP Richardson

Keywords

FAQs

Package last updated on 29 Jan 2013

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