All Projects → tunnckoCore → get-installed-path

tunnckoCore / get-installed-path

Licence: MIT License
Get locally or globally installation path of given package name.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to get-installed-path

Npm Consider
Check package dependencies before installing it
Stars: ✭ 386 (+889.74%)
Mutual labels:  package, install
Compinstall
Delphi utility app to auto-install component packages into IDE
Stars: ✭ 19 (-51.28%)
Mutual labels:  package, install
Nupdate
A comfortable update solution for .NET-applications.
Stars: ✭ 394 (+910.26%)
Mutual labels:  package, install
Pnpm
Fast, disk space efficient package manager -- 快速的,节省磁盘空间的包管理工具
Stars: ✭ 14,219 (+36358.97%)
Mutual labels:  install, modules
PackageProject.cmake
🏛️ Help other developers use your project. A CMake script for packaging C/C++ projects for simple project installation while employing best-practices for maximum compatibility.
Stars: ✭ 48 (+23.08%)
Mutual labels:  package, install
Trex
Package Manager for deno 🦕
Stars: ✭ 433 (+1010.26%)
Mutual labels:  package, modules
Try
Dead simple CLI tool to try Python packages - It's never been easier! 📦
Stars: ✭ 588 (+1407.69%)
Mutual labels:  package, install
Gitpkg
Publish packages as git tags
Stars: ✭ 208 (+433.33%)
Mutual labels:  package, modules
Pkg Ok
👌 Checks paths and scripts defined in package.json before you publish
Stars: ✭ 219 (+461.54%)
Mutual labels:  package, path
Elm Package
Command line tool to share Elm libraries
Stars: ✭ 214 (+448.72%)
Mutual labels:  package, install
get-bin-path
Get the current package's binary path
Stars: ✭ 25 (-35.9%)
Mutual labels:  package, path
lint-deps
Lint for unused or missing dependencies in your node.js projects. Customize with plugins or configuration.
Stars: ✭ 48 (+23.08%)
Mutual labels:  package, modules
requireg
Resolve and require local & global modules in node.js like a boss
Stars: ✭ 45 (+15.38%)
Mutual labels:  modules, path
version-check
An action that allows you to check whether your npm package version has been updated
Stars: ✭ 65 (+66.67%)
Mutual labels:  package
ReplAPI.it-NodeJS
[DEPRECIATED] 𝙀𝙫𝙚𝙧𝙮𝙩𝙝𝙞𝙣𝙜 𝙍𝙚𝙥𝙡𝙞𝙩, 𝙖𝙡𝙡 𝙖𝙩 𝙮𝙤𝙪𝙧 𝙙𝙞𝙨𝙥𝙤𝙨𝙖𝙡. This is the single most extensive Replit package, allowing you to access various parts of the site with just a few classes and methods. Maintained by @RayhanADev.
Stars: ✭ 32 (-17.95%)
Mutual labels:  package
angular-package-builder
[DEPRECATED] Packages your Angular 4+ library based on the Angular Package Format.
Stars: ✭ 25 (-35.9%)
Mutual labels:  package
badgecreatr
Quickly place relevant badges at the top of your readme, stop copy pasting, start on your project
Stars: ✭ 61 (+56.41%)
Mutual labels:  package
action-autotag
Automatically generate a new tag when the manifest file (package.json, Dockerfile, custom file, etc) version changes.
Stars: ✭ 45 (+15.38%)
Mutual labels:  package
Fedora-KDE-Minimal-Install-Guide
Guide to install KDE Plasma desktop environment on a minimal Fedora installation
Stars: ✭ 125 (+220.51%)
Mutual labels:  install
channelHelper
基于walle工具的多渠道打包脚本
Stars: ✭ 35 (-10.26%)
Mutual labels:  package

get-installed-path npm version github release mit License NPM Downloads Total

Get installation path where the given package is installed. Works for globally and locally installed packages

You might also be interested in detect-installed.

Quality Assurance 💯

Code Climate Code Style Standard Linux Build Code Coverage Dependencies Status Renovate App Status Node Version Required

If you have any how-to kind of questions, please read Code of Conduct and join the chat room or open an issue.
You may also read the Contributing Guide. There, beside "How to contribute?", we describe everything stated by the badges.

tunnckoCore support Code Format Prettier Node Security Status Conventional Commits Semantic Release First Timers Only

All Contributors Spec Make A Pull Request Newsletter Subscribe PayPal Author Support Share Love BitHound Code

Table of Contents

(TOC generated by verb using markdown-toc)

Install

This project requires Node.js v6 and above. Use yarn v1 / npm v5 or above to install it.

$ yarn add get-installed-path

API

Review carefully the provided examples and the working tests.

getInstalledPath

Get installed path of globally or locally name package. By default it checks if name exists as directory in global-modules directory of the system. Pass opts.local to get path of name package from local directory or from opts.cwd. Returns rejected promise if module not found in global/local node_modules folder or if it exist but is not a directory.

Params

  • name {string}: package name
  • opts {Object}: pass opts.local to check locally
  • returns {Promise}: rejected promise if name not a string or is empty string

Example

const { getInstalledPath } = require('get-installed-path')

getInstalledPath('npm').then((path) => {
  console.log(path)
  // => '/home/charlike/.nvm/path/to/lib/node_modules/npm'
})

getInstalledPath('foo-bar-barwerwlekrjw').catch((err) => {
  console.log(err.message)
  // => 'module not found "foo-bar-barwerwlekrjw" in path ...'
})

getInstalledPath('npm', {
  local: true
}).catch((err) => {
  console.log(err.message)
  // => 'module not found "foo-bar-barwerwlekrjw" in path ...'
})

getInstalledPath('global-modules', {
  local: true
}).then((path) => {
  console.log(path)
  // => '~/code/get-installed-path/node_modules/global-modules'
})

// If you are using it for some sub-directory
// pass `opts.cwd` to be where the `node_modules`
// folder is.
process.chidr('foo-bar-baz')
getInstalledPath('global-modules', {
  local: true,
  cwd: '../'
}).then((path) => {
  console.log(path)
  // => '~/code/get-installed-path/node_modules/global-modules'
})

// When searching for the path of a package that is required
// by several other packages, its path may not be in the
// closest node_modules. In this case, to search recursively,
// you can use the following:
getInstalledPath('npm', {
 paths: process.mainModule.paths
}).then((path) => {
 // ...
})
// `process.mainModule` refers to the location of the current
// entry script.

getInstalledPathSync

Get installed path of a name package synchronous. Returns boolean when paths option is used and filepath is directory, otherwise returns a full filepath OR throws error.

Params

  • name {string}: package name
  • opts {Object}: pass opts.local to check locally
  • returns {string}: The full filepath or throw TypeError if name not a string or is empty string

Example

const { getInstalledPathSync } = require('get-installed-path')

const npmPath = getInstalledPathSync('npm')
console.log(npmPath)
// => '/home/charlike/.nvm/path/to/lib/node_modules/npm'

const gmPath = getInstalledPathSync('global-modules', { local: true })
console.log(gmPath)
// => '~/code/get-installed-path/node_modules/global-modules'

back to top

Related

back to top

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Please read the Contributing Guide and Code of Conduct documents for advices.

Author

License

Copyright © 2016-2017, Charlike Mike Reagent. Released under the MIT License.


This file was generated by verb-generate-readme, v0.6.0, on October 12, 2017.
Project scaffolded and managed with hela.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].