Socket
Socket
Sign inDemoInstall

import-cwd

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

import-cwd

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


Version published
Weekly downloads
2.8M
decreased by-16.56%
Maintainers
1
Weekly downloads
 
Created

What is import-cwd?

The import-cwd npm package allows users to import modules using a path relative to the current working directory (CWD). This can be particularly useful when you want to require modules without having to worry about the relative path from the current file to the module, especially in complex project structures.

What are import-cwd's main functionalities?

Import module from current working directory

This feature allows you to import a module using a path relative to the current working directory. It's similar to require(), but it resolves paths from the CWD instead of the current file's directory.

const importCwd = require('import-cwd');
const myModule = importCwd('./my-module');

Silent import with fallback

This feature attempts to import a module, but if it fails (e.g., the module does not exist), it will return a fallback value without throwing an error. This is useful for providing default configurations or modules.

const importCwd = require('import-cwd');
const myModule = importCwd.silent('./non-existent-module', 'default-module');

Other packages similar to import-cwd

Keywords

FAQs

Package last updated on 21 May 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