Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create-react-app says "Create React App requires Node 14 or higher." Fixing node gives "npm does not support Node.js v10.19.0"

I was trying to create a react app, but got following

$ npx create-react-app react-demo
npx: installed 67 in 6.045s
You are running Node 10.19.0.
Create React App requires Node 14 or higher. 
Please update your version of Node.

In the solution, this answer asks to run npm i -g npm@latest which gives another error:

$ sudo npm i -g npm@latest
npm does not support Node.js v10.19.0
You should probably upgrade to a newer version of node as we
can't make any promises that npm will work with this version.
You can find the latest version at https://nodejs.org/
/usr/local/lib/node_modules/npm/lib/npm.js:32
  #unloaded = false
  ^

SyntaxError: Invalid or unexpected token
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at module.exports (/usr/local/lib/node_modules/npm/lib/cli.js:22:15)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:2:25)
    at Module._compile (internal/modules/cjs/loader.js:778:30)

Solution to this error asks to uninstall npm which gives same error:

$ sudo npm uninstall -g npm
npm does not support Node.js v10.19.0
You should probably upgrade to a newer version of node as we
can't make any promises that npm will work with this version.
You can find the latest version at https://nodejs.org/
/usr/local/lib/node_modules/npm/lib/npm.js:32
  #unloaded = false
  ^

SyntaxError: Invalid or unexpected token
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    //..
    at Module._compile (internal/modules/cjs/loader.js:778:30)

Solution to above error asks to install helper utility n, which also gives same error:

$ sudo npm install -g n
npm does not support Node.js v10.19.0
You should probably upgrade to a newer version of node as we
can't make any promises that npm will work with this version.
You can find the latest version at https://nodejs.org/
/usr/local/lib/node_modules/npm/lib/npm.js:32
  #unloaded = false
  ^

SyntaxError: Invalid or unexpected token
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    //..
    at Module._compile (internal/modules/cjs/loader.js:778:30)

I am super confused whats happening here. How do I fix this?

PS: am quite new to npm and node.

like image 674
Rnj Avatar asked Nov 24 '25 18:11

Rnj


2 Answers

This worked for me

npm cache clean -f 
sudo npm install -g n
sudo n latest 
like image 164
Sakshi Mahajan Avatar answered Nov 27 '25 09:11

Sakshi Mahajan


My solution was to update ubuntu using $ sudo apt update Then use $ sudo n stable to install the latest version of nodejs

what you need is node manager using npm install -g n to install before using $ sudo n stable

like image 24
Piros_K Avatar answered Nov 27 '25 09:11

Piros_K