2

I've just finished installing create-react-app successfully. But, when I create a new project like below command, error happens. Could you please give me a recommandation?

system env.: - aws lightsail 1vcpu, 0.5G ram / ubuntu 18.04 - nodejs version : 13.9.0 - npm version : 6.13.7 - create-react-app version : 3.4.0

~$ npm create-react-app my-app

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

[email protected] postinstall /home/ubuntu/my-app/node_modules/babel-runtime/node_modules/core-js node -e "try{require('./postinstall')}catch(e){}"

Aborting installation. npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.

Deleting generated file... node_modules Deleting generated file... package.json

Done.

2
  • try npx create-react-app appname Commented Mar 2, 2020 at 10:11
  • Can you try these steps to create a react project? Commented May 31, 2020 at 21:05

3 Answers 3

2

Switch to Yarn

It was a raised issue on github a couple of years back.. it was solved after switching to yarn. These commands could not solve the issue.

npm cache clean --force
create-react-app my-apps

Switching to Yarn worked!

npm install -g yarn
yarn global add create-react-app
create-react-app my-app

See if this helps!

Sign up to request clarification or add additional context in comments.

3 Comments

Aditya issue is not with yarn or any other package installer. It is related to create-react-app command itself.
You are right. But if you could go through the discussions under the closed issue github.com/facebook/react/issues/11933, the conclusion was switching to yarn to get it work. This a work around. If this is fixed by now in the cra , suggest an edit to this answer. Thanks
Even in Linux, using yarn, a wrong bash path is assumed as core-js tries to run script inside SHELL, so your alternative solution is not a universal solution, ultimately one has to find how to deal with facebook/create-react-app mess!
2

This error is due to the fact that a dependant module named core-js is trying to run a post-install script. This post-install script spawns a child process and runs a shell script there. For some reason Node sets/assumes a wrong bash path by default. I had to manually change the path by running the following command.

npm config set script-shell $(which sh)

Note: For Windows you might have to setup your own bash.exe by installing something like git-bash and then you could assign the path similarly.

1 Comment

thank you this worked for me, I also found this question related on how to set it, if it helps: stackoverflow.com/a/46006249/10945921
0

Try this: npm cache clean --force

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.