3.0.0 • Published 7 years ago

import-cwd v3.0.0

Weekly downloads
8,121,569
License
MIT
Repository
github
Last release
7 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_ck@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-popupsaqa_framework_poctailwind-templatewodax-rollup-plugin-postcss-umivue-button-test1wordsbywtf-webpack-configstories-react-bdstart-deepsweet-react-components-monorepo-presetspencesvavatarvue-compmentvision-camera-plugin-scan-facesvenus-scriptsvs-tree-plus@bung87/rollup-plugin-postcss@bung87/svg-sprite@bung87/icon-gen@benjamin-vanryseghem/rollup-plugin-postcssjesusdemojson-chewerjeshjnf-accesscontrol-rnttljumbo-test-apihotswap-modulehot-zone-vuehornet-js-builderhandle-thathantil-csshelp-widgetlint-to-the-futurelint-to-the-future-eslintlint-to-the-future-stylelintlitepie-datepicker-gabelerna-emojim2m-chartjs-plugin-crosshairkunkkakrown_login_librarymavectrametalsmith-dart-sass@webbio/rollup-plugin-postcss-webbio@wecraftapps/react-native-use-keyboard@vue-helper/vue-keep-alive@x-ray/react@tillschweneker/ckeditor5-build-strapi-wysiwyg-markdown@viewfly/devtools@yplabs-ltd/react-native-detector@xuna08/scaffold_builder@yak-spirit/yak-swap-ui@ykominami/xcomp@yutengjing/ts-fix@zhijianren/rollup-plugin-postcss@zecrey/cra-build-watch@zero-cli/subcommand-jest@zero-cli/zero-test@zebracompany/f_editorafter-work.jsagora-app-builder-cliagora-app-builder-cli-testaditya-app-builder-cliant-design-draggable-modal-fixap-vue-captchaappcharge-checkout@graines-digitales/nice-handsome-button@36node/sketch@happy-gastro/react-native-printer-module@gridonic/webpack@a11ygato/cli@gstamac/dry-dry@after-work.js/transform@after-work.js/transform-middleware@after-work.js/utils@after-work.js/babel@after-work.js/cdp
3.0.0

7 years ago

2.1.0

8 years ago