near-cli icon indicating copy to clipboard operation
near-cli copied to clipboard

State the minimal required Node.js version in the README

Open frol opened this issue 4 years ago • 13 comments

It would be great to also integrate the check into the near-shell itself, so it does not produce cryptic errors like:

 $ near new_project staking
 node: bad option: --experimental-repl-await

It seems that Node.js 10+ is now required.

frol avatar Nov 12 '19 10:11 frol

Added to package.json for now https://github.com/nearprotocol/near-shell/blob/master/package.json#L6

Good point about better runtime check. Kinda can live without that flag, but never tested on anything smaller than 10. It's not even current LTS anymore :)

vgrichina avatar Nov 15 '19 06:11 vgrichina

if we keep seeing this issue we can try adding engineStrict = true

amgando avatar Nov 16 '19 17:11 amgando

@amgando this happens before we are even in Node.js code though

vgrichina avatar Nov 19 '19 00:11 vgrichina

oh. it's here, my bad

#!/bin/sh
CLI_PATH="$(dirname "$0")"/near-cli.js
node --experimental-repl-await "$CLI_PATH" "$@"

how complicated do we want to make the bootstrapping script?

here's a little something i like to call overkill

requirement 1: node

near@everywhere:$ near

NEAR Shell requires node
Please get it here: https://nodejs.org/en/download

requirement 2: min version

near@everywhere:$ near

NEAR Shell requires node version 10 or greater
You currently have node v8.16.2 installed
Kindly upgrade your node environment ftw

all requirements met: NEAR Shell launches


note: this was only tested on one machine

Darwin machbuch.local 19.0.0 Darwin Kernel Version 19.0.0: Thu Oct 17 16:17:15 PDT 2019; root:xnu-6153.41.3~29/RELEASE_X86_64 x86_64
#!/bin/sh
set -e

# configure requirements
REQUIRED_NODE_VERSION=10

# --------------------------------

function missing {
  local return_=1
  type $1 >/dev/null 2>&1 || { local return_=0; }
  return $return_
}

function launch_near_shell {
  CLI_PATH="$(dirname "$0")"/near-cli.js
  node --experimental-repl-await "$CLI_PATH" "$@"
}

# --------------------------------

if missing node; then
  echo
  echo "NEAR Shell requires node"
  echo "https://nodejs.org/en/download"
  echo
else

  version=`node -v`
  major=${version:1:2}

  if [ $major -ge $REQUIRED_NODE_VERSION ]
  then
    launch_near_shell
  else
    echo
    echo "NEAR Shell requires node version $REQUIRED_NODE_VERSION or greater"
    echo "You currently have node $version installed"
    echo "Kindly upgrade your node environment ftw"
    echo
  fi
fi

amgando avatar Nov 19 '19 07:11 amgando

@amgando your solution implies that sh is available. Is it always the case for node environments on Windows? (Does near-shell work on Windows?)

frol avatar Nov 23 '19 08:11 frol

@frol not sure, will try to setup AppVeyor this week for CI to include windows unless we already have something going to answer this question.

amgando avatar Nov 25 '19 08:11 amgando

@amgando I suggest we better use GitHub Actions. It is a new built-in CI with all three major platforms available.

frol avatar Nov 25 '19 08:11 frol

oh? perfect, i'll look at that then, thanks!

amgando avatar Nov 25 '19 08:11 amgando

I’d prefer we stick to Travis. They also have windows env available afaik.

vgrichina avatar Nov 25 '19 19:11 vgrichina

I have just searched and indeed there is an early preview of Windows support on Travis. What are the concerns about Github Actions? We use it for Explorer and it seem to work just fine.

frol avatar Nov 25 '19 19:11 frol

@frol Travis has better UX IMO, but yeah difference is small. However I feel a bit uneasy about MS owning yet another part of dev stack :/

vgrichina avatar Nov 26 '19 06:11 vgrichina

Confirmed that adding engineStrict = true doesn't solve the problem.

janedegtiareva avatar Jan 07 '20 00:01 janedegtiareva

Needs bump to 12.

behaviary avatar May 12 '20 17:05 behaviary