3.0.0 • Published 6 years ago

import-cwd v3.0.0

Weekly downloads
8,121,569
License
MIT
Repository
github
Last release
6 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@dotcom-tool-kit/create@dimcheify/dimui@cristianps1988/ds-template@csmith/release-it@ct-note/table@ct-note/image@ct-note/list@ct-note/checklist@ct-note/embed@corelmax/react-native-my2c2p-sdk@dinert/component@dougalg/rollup-plugin-postcss@bung87/rollup-plugin-postcss@bung87/svg-sprite@bung87/icon-gen@benjamin-vanryseghem/rollup-plugin-postcss@rubybb/ts-fixjesusdemojson-chewerjeshjnf-accesscontrol-rnttljumbo-test-apisr-commit-analyzersr-release-notes-generatorstock-ticker-react-widgettype-libarytingzi-vuepressu-librarytldrawlignin@apardellass/react-native-audio-stream@aristidenf/streak-counter@auto-canary/core@arkasuryawan/m2-interface@auto-it/core@alfalab/rollup-plugin-postcss@after-work.js/babel@after-work.js/cdp@after-work.js/cli@after-work.js/interactive-plugin@after-work.js/node@after-work.js/preset-plugin@after-work.js/protractor@after-work.js/puppeteer@after-work.js/register@after-work.js/server@after-work.js/transform@after-work.js/transform-middleware@after-work.js/utils@blendle/rollup-plugin-postcss@carhoo/widget-dealers@byu-oit/aim-nuxt-builder@carbonorm/rollup-plugin-postcss@36node/sketch@a11ygato/cli@codemucker/npm-dry@design-systems/core@devorso/dcountdown@contagt/metismenu@darraghmckay/cra-build-watch
3.0.0

6 years ago

2.1.0

8 years ago