Skip to content
This repository has been archived by the owner on Jul 6, 2019. It is now read-only.

feat(node-path): append temp packages to $NODE_PATH #180

Open
wants to merge 1 commit into
base: latest
Choose a base branch
from

Conversation

zkat
Copy link
Owner

@zkat zkat commented May 3, 2018

Ref: #160

This makes it so you can do npx -p lodash node -r lodash when lodash is not
already installed. One big downside of this patch is that because of the semantics
of that node feature, NODE_PATH will always be treated as a fallback. That is, if
you already have one version of lodash installed in a local npm project you're
currently in the directory of, you won't be able to override it with the
temporary install.

This was referenced May 3, 2018
@zkat zkat force-pushed the zkat/support-node-path branch 2 times, most recently from 066203e to a6b2fc0 Compare May 3, 2018 22:18
Fixes: #153
Ref: #160

This makes it so you can do `npx -p lodash node -r lodash` when lodash is not
already installed. One big downside of this patch is that because of the semantics
of that node feature, NODE_PATH will always be treated as a _fallback_. That is, if
you already have one version of lodash installed in a local npm project you're
currently in the directory of, you won't be able to override it with the
temporary install.
@jasisk
Copy link

jasisk commented Aug 6, 2018

I threw together a sloppy, terribad, not OS-independent workaround while we wait for this one.

$ npx -q -p lodash -p @sisk/npx repl -e "console.log(require('lodash').VERSION)"
4.17.10

$ npx -q -p lodash -p @sisk/npx exec sh -c 'echo ${NODE_PATH}'
/Users/kittens/.npm/_npx/80711/lib/node_modules

The bins are this nightmare:

#!/bin/sh
NODE_PATH="$(printf "%s" "$PATH" | sed -e 's/:.*$//' -e 's:/[^/]*$::')"
[ "${0##*/}" = 'repl' ] && set -- node "$@"
exec env NODE_PATH="$NODE_PATH/lib/node_modules" "$@"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants