JSPM

resolve-package

0.2.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 98115
  • Score
    100M100P100Q150797F
  • License MIT

Resolves a given package if it is installed locally, then tries to resolve it from global. Better approach than require.resolve

Package Exports

  • resolve-package

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (resolve-package) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

resolve-package NPM version NPM downloads npm total downloads

Resolves a given package if it is installed locally, then tries to resolve it from global. Better approach than require.resolve

code climate standard code style linux build status windows build status coverage status dependency status

You might also be interested in always-done.

Table of Contents

(TOC generated by verb using markdown-toc)

Background

Why

TODO

Resolution

TODO

Install

Install with npm

$ npm install resolve-package --save

or install using yarn

$ yarn add resolve-package

Usage

For more use-cases see the tests

const resolvePackage = require('resolve-package')

API

resolvePackage

Get full absolute path of package with name from local node_modules or from globally installed.

Params

  • name {String}: package name
  • opts {Function}: optional options such as below
  • opts.cwd {String}: directory where is the node_modules folder
  • opts.mainFile {String}: main file for directories, default index.js
  • opts.mainField {String}: name of the package.json's "main" field, default main
  • returns {Promise}

Example

const resolvePackage = require('resolve-package')

resolvePackage('npm').then((fp) => {
  console.log(fp)
  // => '~/.nvm/versions/node/v7.0.0/lib/node_modules/npm/lib/npm.js'
})

resolvePackage('standard').then((fp) => {
  console.log(fp)
  // => '~/.nvm/versions/node/v7.0.0/lib/node_modules/standard/index.js'
})

resolvePackage('get-installed-path').then((fp) => {
  console.log(fp)
  // => '~/code/resolve-package/node_modules/get-installed-path/index.js'
})

resolvePackage('foo-quqixs-dasdasdh').catch((err) => {
  console.error(err) // => Error module not found
})
  • always-done: Handle completion and errors with elegance! Support for streams, callbacks, promises, child processes, async/await and sync functions. A drop-in replacement… more | homepage
  • minibase: Minimalist alternative for Base. Build complex APIs with small units called plugins. Works well with most of the already existing… more | homepage
  • try-catch-core: Low-level package to handle completion and errors of sync or asynchronous functions, using once and dezalgo libs. Useful for and… more | homepage

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Please read the contributing guidelines for advice on opening issues, pull requests, and coding standards.
If you need some help and can spent some cash, feel free to contact me at CodeMentor.io too.

In short: If you want to contribute to that project, please follow these things

  1. Please DO NOT edit README.md, CHANGELOG.md and .verb.md files. See "Building docs" section.
  2. Ensure anything is okey by installing the dependencies and run the tests. See "Running tests" section.
  3. Always use npm run commit to commit changes instead of git commit, because it is interactive and user-friendly. It uses commitizen behind the scenes, which follows Conventional Changelog idealogy.
  4. Do NOT bump the version in package.json. For that we use npm run release, which is standard-version and follows Conventional Changelog idealogy.

Thanks a lot! :)

Building docs

Documentation and that readme is generated using verb-generate-readme, which is a verb generator, so you need to install both of them and then run verb command like that

$ npm install verbose/verb#dev verb-generate-readme --global && verb

Please don't edit the README directly. Any changes to the readme must be made in .verb.md.

Running tests

Clone repository and run the following in that cloned directory

$ npm install && npm test

Author

Charlike Mike Reagent

License

Copyright © 2016, Charlike Mike Reagent. Released under the MIT license.


This file was generated by verb-generate-readme, v0.2.0, on December 13, 2016.
Project scaffolded using charlike cli.