The create-react-app displays failed.

Asked 1 years ago, Updated 1 years ago, 55 views

I got an error when I did the following.

create-react-app react_lessons
Creating a new React app in /var/www/html/react_lessons/react_lessons.

Installing packages. This light take a couple minutes.
Installing react-scripts...

npm WARN optional dep failed, continuing [email protected]
npm install --save-dev --save-exact react-scripts failed

The above error occurred more than 30 minutes after executing the command.

When I checked the directory, it seems that the files have been generated.
The package.json was also automatically generated, so I checked and found only the following description.

"name":"react_lessons",
"version": "0.1.0",
"private"—true

I wonder if the react-scripts installation has failed.
What is the best solution for these situations?

Error running npm install-g create-react-app as supplementary information
When I tried again with sudo, I was able to do it.

node.js reactjs

2022-09-30 21:22

2 Answers

I'll write it down because it's been solved after a lot of research and testing.
The compatibility between react.js, reactdom.js, and browser.min.js in the label is probably
There seems to be a high possibility that it was bad.

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.2.1/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.2.1/react-dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.min.js"></script>

It worked well here in our environment.
I'm sorry if I gave you the wrong information due to the root cause.
I am sorry to trouble you, but I would appreciate it if you could point it out.


2022-09-30 21:22

You do not need to use sudo to install create-react-app. How did you install npm?

$whichnpm
/Users/<username>/.nodebrew/current/bin/npm


Also, try a directory that is not /var/www/html/.

$cd to
$ npx create-react-app react-lessons


2022-09-30 21:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.