The node version is different when I ssh into an instance than when I do it manually

it would be amazing if you could help me with this.

When I run node -v manually on a GCE instance, it indicates that the node version is v12.18.3 But when I run it with this other command from the Cloud Shell:

gcloud compute ssh [USER]@[GCE instance] --zone [ZONE] --project [PROJECT ID] --command "node -v"

It indicates that the node version is v14.17.1

Why is this happening? How can I make it to the v12.18.3 version ? I need it because my Vue application will not work properly with the version 14 of node.

Extra information:

nvm ls
->     v12.18.3
default -> 12.18.0 (-> v12.18.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v12.18.3) (default)
stable -> 12.18 (-> v12.18.3) (default)
lts/* -> lts/fermium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.1 (-> N/A)
lts/fermium -> v14.17.1 (-> N/A)
  • My npm version is 6.14.6
  • My nvm version is 0.38.0


There is likely more than one version of that binary present on the host, and depending where you execute the command from, the PATH might be set differently which in turn selects a a different binary to run.

You can run which -a node on the host to find all versions of that binary, and then run them with the full path i.e /usr/local/bin/node -v to find out which one is being loaded under which conditions.

After that I believe you can remove the offending one or change the PATH variable to load the correct one.