npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

use-local-modules

v0.2.5

Published

This is a simple npm CLI tool to quickly add local `./node_modules/.bin` to environment PATH variable for current session only.

Downloads

24

Readme

What

This is a simple npm CLI tool to quickly add local ./node_modules/.bin to environment PATH variable for current session only.

This package installs 3 scripts to your npm's global packages directory that it gets by running npm bin -g. Scripts are made for Windows CMD / PowerShell (usemodules.cmd / usemodules.ps1) and unix Bash (usemodules.sh). Each script checks whether local ./node_modules/.bin exists and then adds it to the current sessions PATH variable. The change is not persistent and will be valid for current session only.

In windows while calling usemodules in CMD it will prioritize .cmd files while PowerShell will opt for .ps1 files. For unix systems .sh script is installed without extension so it would be available by just it's name.

Tested with Nodejs v4.0.0 and NPM v2.14.2 in Windows 10 Pro, Windows Linux Subsystem (Ubuntu flavor), Ubuntu 16.04, OSX High Sierra 10.13.3.

Why

I know there's npx and yarn, but I needed something that worked with old node v4 and didn't conflict with npm scripts and wouldn't install packages if they were missing. I just needed a quick env setup to play with commands and then paste them into npm scripts.

Usage

Windows CMD/PowerShell

usemodules

OSX/Linux Bash

. usemodules

You have to execute it in current scope: . usemodules, calling source usemodules will also work, but it's obviously longer to type.

-g argument
-g : Prioritize global

Default behaviour is to prepend directory to global PATH to look there before global bin folder, passing -g argument will append directory to global PATH instead, this will prioritize global packages over local.

Output of the command will show you whether ir prepended or appended:

user@WORKSTATION:~/dev/MyProject$ . usemodules
~/dev/MyProject/node_modules/.bin : >PATH

user@WORKSTATION:~/dev/MyProject$ . usemodules -g
~/dev/MyProject/node_modules/.bin : PATH<
Examples

CMD

Microsoft Windows [Version 10.0.16299.192]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Dev\MyProject>gulp -v
'gulp' is not recognized as an internal or external command,
operable program or batch file.

C:\Dev\MyProject>usemodules
C:\Dev\MyProject\node_modules\.bin : >PATH

C:\Dev\MyProject>gulp -v
[14:25:32] CLI version 2.0.1
[14:25:32] Local version 4.0.0-alpha.3

PowerShell

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Dev\MyProject> which gulp
which : The term 'which' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ which gulp
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (which:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Dev\MyProject> usemodules
C:\Dev\MyProject\node_modules\.bin : >PATH
PS C:\Dev\MyProject> which gulp
C:\Dev\MyProject\node_modules\.bin\gulp.CMD

OSX/Linux

Last login: Mon Mar 12 15:30:06 on ttys002

user@WORKSTATION:~/dev/MyProject$ istanbul
istanbul: command not found
user@WORKSTATION:~/dev/MyProject$ . usemodules
~/dev/MyProject/node_modules/.bin : >PATH
user@WORKSTATION:~/dev/MyProject$ istanbul
Need a command to run
Try "istanbul help" for usage