Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

req-cwd

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

req-cwd

Require a module like `require()` but from the current working directory


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

req-cwd Build Status

Require a module like require() but from the current working directory

Install

$ npm install --save req-cwd

Usage

const reqCwd = require('req-cwd');

// target module at '/Users/sindresorhus/unicorn/foo.js'

console.log(__dirname);
//=> '/Users/sindresorhus/rainbow'

console.log(process.cwd());
//=> '/Users/sindresorhus/unicorn'

reqCwd('./foo');

API

reqCwd(moduleId)

Like require(), throws when the module can't be found.

reqCwd.silent(moduleId)

Returns null instead of throwing when the module can't be found.

moduleId

Type: string

What you would use in require().

  • req-from - Require a module from a given path
  • resolve-from - Resolve the path of a module from a given path
  • resolve-cwd - Resolve the path of a module from the current working directory
  • lazy-req - Require modules lazily

License

MIT © Sindre Sorhus

Keywords

FAQs

Package last updated on 06 Dec 2015

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