Home > Back-end >  create-react-app says "Create React App requires Node 14 or higher." Fixing node gives &qu
create-react-app says "Create React App requires Node 14 or higher." Fixing node gives &qu

Time:12-21

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.

CodePudding user response:

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

CodePudding user response:

I had the same problem. Follow the instructions in https://github.com/nodejs/help/wiki/Installation and your installation will be fine.

Basically, you need to download the binary file installation, and follow the instructions changing the version only.

  • Related