Fresh install of n can't be used
Lovasz-Akos opened this issue · comments
Bug Report
Summary
Just installed n with npm install -g n
and using n latest
breaks
Steps to Reproduce
npm install -g n
n latest
Expected Behaviour
Installs latest nodejs
Actual Behaviour
$ n latest
/bin/n: line 108: syntax error: unexpected "("
Configuration Details
$ n --version
also returns
/bin/n: line 108: syntax error: unexpected "("
$ command -v node
/bin/node
$ node -p process.platform
linux
fixed by using the POSIX compliant version on the POSIX branch
I'm using sh, not bash, that might be the issue here
The n
script starts with a shebang interpreter directive to use bash:
So in theory you can use sh
(or zsh
et al) as your shell, but the n
script is interpreted using bash
.
What version of Bash are you using in the failing environment?
Assuming you have a bash available, what I meant was what version is it? For example, I see:
% bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin21)
Copyright (C) 2007 Free Software Foundation, Inc.
Sadly no bash, it's a super barebones buildroot system i'm testing, I don't even have apt
or curl
which makes changing node versions...difficult. n
comes to save the day, since I do have npm
, but that syntax breaks on sh
. #751 's changes fix this so I'm looking forward to it's merge or completion :)
Thanks for the info. A vote for the posix compatible version. :-)
(although it acted a little strange on my try, n's tui only saw the version it installed and not the one already present on the system, and it couldn't switch my active install)
and it couldn't switch my active install
That sounds like an issue with node installed twice, likely once into /usr/bin
(by some other process) and into /usr/local/bin
by n
. The version which is found depends on the order of directories in the PATH
environment variable.
If you run n doctor
it will check for this situation.