3.0.0 • Published 5 years ago

import-cwd v3.0.0

Weekly downloads
8,121,569
License
MIT
Repository
github
Last release
5 years ago

import-cwd Build Status

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

Install

$ npm install import-cwd

Usage

const importCwd = require('import-cwd');

// Target module is at '/Users/sindresorhus/unicorn/foo.js'

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

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

const foo = importCwd('./foo');

API

importCwd(moduleId)

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

importCwd.silent(moduleId)

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

moduleId

Type: string

What you would use in require().

Related

  • import-from - Import 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
  • resolve-pkg - Resolve the path of a package regardless of it having an entry point
  • import-lazy - Import modules lazily
  • import-global - Import a globally installed module

License

MIT © Sindre Sorhus

@kraken.js/clivuedragdropuploadimagesreact-native-bluetooth2@bumble/dot-plop@bumble/plop-md@activecampaign/camp-utilitycloud-archive-s3airscanairscan-examplebb-chatreact-native-esc-pos-sahaab@borisovart/atol-kkt-moduledeneme323112@fundefund/funde_ckslank@ntt_app/react-native-custom-notificationtarkov-scannerreact-native-covid-sdk@olivervorasai/sliderreact-native-printer-brotherscogoportutils@infinitebrahmanuniverse/nolb-imp@saaspe/componentsexpand-react-bridge@everything-registry/sub-chunk-1908flows-syncp149-tabletest-popupsdevextreme-clidot-plopdry-drydry-dry-revisedvue-button-test1engine-auditemoji-commit-helperszoro-cli-utilreact-native-badge-controlreact-native-biometric-authenticate@noloco/cra-build-watch@ols-scripts/pluginreact-native-contact-listreact-native-dsphoto-modulereact-native-cplusreact-native-create-video-thumbnailreact-native-bubble-chartreact-native-is7react-native-jsi-device-inforeact-native-kakao-mapsreact-native-flyyreact-lightbox-pack-18support@nppkg/react-dnd@slater/rollup-plugin-postcss@ornikar/rollup-plugin-postcss@oriduk/ckeditor5-rebuild-musicanote@oriduk/ckeditor5-rebuild-oridukreac-native-arun-ramya-test@sanch941/configs-webpackpulpweaver@osdev/rollup-plugin-postcss@rubybb/ts-fix@sak1sham/react-toc-highlight@saad27/react-native-bottom-tab-tourreact-dottie@scriptappy/cliemr-tabulator-tablesvue-compmenteslint-dashboardvue3-google-login-with-statees-react-bridgef_yoship147-tablep148-tableex-ikon-components-librarynpm_qwertynpm_one_12_34_1_npm_one_1_2_3npm_one_2_2flowable-bpmn-modelergarnish-uigatsby-plugin-wordsbyreact-native-plugpag-wrapperreact-native-responsive-sizereact-native-modal-progress-barhelp-widgetreact-native-sayhello-module@sounisi5011/metalsmith-netlify-published-date@southcn/ckeditor5-build-inline@tillschweneker/ckeditor5-build-strapi-wysiwyg-markdownreact-native-test-module-hhh@quarkd/rollup-plugin-postcssreact-native-syan-photo-pickerreact-native-transtracker-library@rea-scripts/pluginreact-solid-gradient-picker@stansaal/ckeditor5-custom-buildreact-native-ytximkitreact-native-payu-payment-testingreact-native-pulsator-native@spencejs/spence-config@spencejs/spence-core
3.0.0

5 years ago

2.1.0

7 years ago