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

resolve-cwd

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resolve-cwd

Resolve the path of a module like `require.resolve()` but from the current working directory

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is resolve-cwd?

The resolve-cwd npm package is a utility that allows you to resolve the path of a module or file based on the current working directory (CWD). This can be particularly useful in scenarios where you need to require modules dynamically based on the execution context or when working with tools that change the current working directory.

What are resolve-cwd's main functionalities?

Resolve module path from CWD

This feature allows you to resolve the path of a module from the current working directory. It's useful when you need to require a module dynamically and the module's location is relative to where the script is being executed.

const resolveCwd = require('resolve-cwd');
const modulePath = resolveCwd('some-module');
console.log(modulePath);

Silent failure on non-existent module

This feature provides a way to attempt to resolve a module's path without throwing an error if the module does not exist. It's useful for cases where you want to check for a module's presence and handle the absence gracefully.

const resolveCwd = require('resolve-cwd');
const modulePath = resolveCwd.silent('non-existent-module');
if (modulePath) {
  console.log('Module found at:', modulePath);
} else {
  console.log('Module not found');
}

Other packages similar to resolve-cwd

Keywords

FAQs

Package last updated on 30 Apr 2019

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