By default, there's not a way to upgrade the version of Node.js you've got from within Node.js itself.
That said, there's a fantastic tool for the community called nvm that allows you to manage the versions of Node.js that you've got installed locally.
This is the what I see on circleci. The step fails but without a specific error.
#!/bin/bash -eo pipefail
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash
source ~/.bashrc
nvm install v6.11.1
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 12461 100 12461 0 0 160k 0 --:--:-- --:--:-- --:--:-- 162k
=> nvm is already installed in /opt/circleci/.nvm, trying to update using git
=> => Compressing and cleaning up git repository
=> nvm source string already in /home/circleci/.bashrc
=> Appending bash_completion source string to /home/circleci/.bashrc
npm ERR! peer dep missing: eslint@>=3.1.0, required by eslint-plugin-node@5.2.0
=> You currently have modules installed globally with `npm`. These will no
=> longer be linked to the active version of Node when you install a new node
=> with `nvm`; and they may (depending on how you construct your `$PATH`)
=> override the binaries of modules installed with `nvm`:
/opt/circleci/.nvm/versions/node/v6.1.0/lib
├── bower@1.8.2
├── coffee-script@1.12.7
├── grunt@1.0.1
├── grunt-cli@1.2.0
├── mocha@4.0.0
├── nodeunit@0.11.1
=> If you wish to uninstall them at a later point (or re-install them under your
=> `nvm` Nodes), you can remove them from the system Node as follows:
$ nvm use system
$ npm uninstall -g a_module
=> Close and reopen your terminal to start using nvm or run the following to use it now:
export NVM_DIR="/opt/circleci/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Downloading and installing node v6.11.1...
Downloading https://nodejs.org/dist/v6.11.1/node-v6.11.1-linux-x64.tar.xz...
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v6.11.1 (npm v3.10.10)
Exited with code 1
It seems to be playing up when I try to load nvm with [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh. If I remove that line the output is the same but the step passes. Of course if I do nvm --version it will throw an error that the nvm command is not found as I haven’t loaded it yet.