this is my first time trying to update the nodejs version of a unix server. I want to use it to create a react app, and facing the following:
>npx create-react-app test
You are running Node 8.11.3.
Create React App requires Node 10 or higher.
Please update your version of Node.
So I have tried to update the version with the following commands:
>sudo npm cache clean -f
>sudo npm install -g n
>sudo n stable
installed : v14.15.4 to /usr/local/bin/node
active : v8.11.3 at /bin/node
However it seems that didn't upgrade the version, it installed a different version in a different path.
I am not sure if it is possible just to upgrade the version that is already active, I prefer not to do a workaround and just upgrade it directly.
As complementary information if I run n doctor I see the following:
>n doctor
Checking n install destination is in PATH...
'/usr/local/bin' is not in PATH
As I said previously, what I am looking for is a safe way to update the version already installed to be able to use create-react-app, being able to rollback to previous version easily if something doesn't work, I understand that the way is using n.
Thanks in advance.
I suggest you add
/usr/local/binto the start of yourPATH(so it comes before/bin).I do not recommend you try and overwrite
/bin/nodeusingn. Something else installed/bin/nodein a system directory, and overwriting it usingncould leave things in a mixed and confused state.ninstalls to/usr/localby default, but you can setN_PREFIXto install to your home folder, for example.To avoid confusion with having two versions of node installed, you may wish to uninstall the
/binversion, likely installed by your platform package manager.Tip: Changing where node and npm are installed is likely to change where your global npm packages are installed. I suggest you list what you have installed now in case you want to reinstall then in the "new" location.
npm list -g --depth=0