简体   繁体   中英

having an issue creating new react app with create-react-app

I am trying to create a new react project, but when I run npx create-react-app tik-tok-clone I get the following error

    Creating a new React app in C:\Users\mwars\Documents\GitHub\TikTok-Clone\tik-tok-clone.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

yarn add v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
error postcss@8.1.3: The engine "node" is incompatible with this module. Expected version "^10 || ^12 || >=14". Got "13.12.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Aborting installation.
  yarnpkg add --exact react react-dom react-scripts cra-template --cwd C:\Users\mwars\Documents\GitHub\TikTok-Clone\tik-tok-clone has failed.

Deleting generated file... package.json
Deleting generated file... yarn.lock
Deleting tik-tok-clone/ from C:\Users\mwars\Documents\GitHub\TikTok-Clone
Done.

I've been trying to figure it out for a while now and just can't get it to work.

I am was dealing with the same problem and have managed to understand and fix it. I will try to explain it below.

The issue:

error postcss@8.1.3: The engine "node" is incompatible with this module. Expected version "^10 || ^12 || >=14". Got "13.12.0"

This is telling you that the create_react_app module is only compatible with versions 10 , 12 , or greater than 14 of node and you are using 13.12.0 .

The solution

To fix this error you need to either upgrade or downgrade your current version of node .

One way to do this is to use NVM (node version manager) to manage multiple versions of node .

To install it with either Linux or Mac you can use either of the following commands

For Wget, run the following command on the terminal:

  wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

For CURL, run the following:

  curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

You will want to change the version number in the commands to the latest stable version.

Once you have downloaded it successfully restart the terminal or you won't be able to find it. If this fails you may need to reset your computer.

If you have NVM installed running the following should show you the current version of it your using.

nvm --version

You can then use the following command to list available versions of node

nvm ls-remote

Select a compatible version and install it like so

nvm install 14.15.0

Running

node -v 

Should show this as your current version if not try

nvm use v14.15.0

You should now have no issues running

npx create-react-app tik-tok-clone

It worked for me after running these commands.

  1. sudo npm cache clean -f //clear you npm cache

  2. sudo npm install -gn install n //(this might take a while)

  3. sudo n stable upgrade //to the current stable version

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM