Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"n use" style command for invoking npm #185

Closed
tjwebb opened this issue Jul 3, 2014 · 8 comments
Closed

"n use" style command for invoking npm #185

tjwebb opened this issue Jul 3, 2014 · 8 comments
Milestone

Comments

@tjwebb
Copy link
Collaborator

tjwebb commented Jul 3, 2014

n use <version> runs node as a particular version. I think it'd be useful to also be able to run npm in this manner as well. The CLI could then look something like:

  1. install: $ n <version>
  2. run node: $ n <version> node (or currently, $ n use <version>)
  3. run npm: $ n <version> npm
@bfricka
Copy link

bfricka commented Aug 3, 2014

+1 This would be very useful. In its current incarnation, the results are weird. For example, this happened today:

# From v0.10.29
brew upgrade node
...
node -v
v0.10.30
npm -v
1.4.23

Then check n:

n # gets stuck in limbo b/c brew took over
n stable # Installs v0.10.30
node -v
v0.10.30
npm -v
1.4.23

Cool. Makes sense. But...

n latest
node -v
v0.11.13
npm -v
1.4.9

:(. Switch back

n stable
node -v
v0.10.30
npm -v
1.4.21 # F*ck

Thus, every n switch requires npm to be updated to the desired version.

@ghost ghost removed the 1.3.x label Jul 22, 2015
@ghost ghost added this to the 2.1.0 milestone Jul 22, 2015
@maxrimue maxrimue mentioned this issue Sep 17, 2015
5 tasks
@wprater
Copy link

wprater commented Dec 30, 2015

this is a great idea for running scripts as a certain version. progress?

@bitdivine
Copy link

There is a sketch implementation of how this might work in #192

Usage:

n with <version> npm install

Code: https://github.com/bitdivine/n

This is not ready for merging into master but I find it useful to have a working implementation to play with to make sure that the feature implements all the goodies it promises.

@bitdivine
Copy link

Do the above semantics work for you? They are:

+    n npm <version> [args ...]     Execute npm with node <version> and [args ...]
+    n with <version> [command ...] Execute command with the given version of node at the front of the PATH.

If so I can make the implementation more robust and send you a pull request.

@shadowspawn
Copy link
Collaborator

I suggest following same syntax as nvs and nvm which both have an exec command:

n exec <version> [command ...]

So running npm could look like:

n exec lts npm --version

@shadowspawn
Copy link
Collaborator

This is not likely to make it to n anytime soon. I have implemented this in nvh if any readers would like to give it a try.

@shadowspawn
Copy link
Collaborator

shadowspawn commented Aug 3, 2019

Prerelease available via npm i n@next for v6. Release notes: https://github.com/tj/n/releases/tag/6.0.0-0

@shadowspawn
Copy link
Collaborator

Added n exec in v6: https://github.com/tj/n/releases/tag/v6.0.0

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

No branches or pull requests

5 participants