2

I have no knowledge of react and npm . In order to to learn react i am tried to follow this tutorial a youtube link!

i was instructed to run npm i -g [email protected] but i accidentally ran npm i -g create-react-app

now the files (e.g app.js) that are created are different from the tutorial

With my limited understanding i believe what has happened is that the latest version of create-react-app has got installed in my windows 10 system, and simply running npm i -g [email protected] now, is not helping me to downgrade to desired version.

=====Edit

No soluition still -

what i tried

a) - npm uninstall -g create-react-app followed by npm i -g [email protected]

b) rm -rf $DIR replace $DIR with the name of the directory created by create-react-app then rerun create-react-app

The app.js is still different from the one generated i the tutorial.

To illustrate what is the difference between two app.js files, ----

app.js using 1.5.2 - tutorial screenshot]

app.js using 1.5.2

app.js that is getting created on my system.

import React from 'react'; import logo from './logo.svg'; import './App.css'; function App() { return ( <div className="App"> <header className="App-header"> <img src={logo} className="App-logo" alt="logo" /> <p> Edit <code>src/App.js</code> and save to reload. 

Edit 2 =======

I found a solution. I have posted the answer.

6
  • That should work for downgrading. Unless you mean you expect downgrading create-react-app to change the files in your project to the previous version? Commented Jun 16, 2019 at 4:01
  • Delete the files that your original create-react-app command made and run it again. Downgrading your global CRA module isn't gonna change any existing files in your project Commented Jun 16, 2019 at 4:03
  • yes, how to change the files, since I can't follow the tutorial otherwise. Commented Jun 16, 2019 at 4:03
  • rm -rf $DIR replace $DIR with the name of the directory created by create-react-app then rerun create-react-app Commented Jun 16, 2019 at 4:04
  • @SoZettaSho does't work - see my edits Commented Jun 16, 2019 at 4:33

2 Answers 2

3

I am answering my onw question.

I am able to get the app.js i wanted to create matching the tutorial by using this command

create-react-app my-react-proj01 [email protected] 

I saw that the react-scripts version in package.json of youtube tutorial was 1.1.4

I found the solution by reading this link hello-create-react-app-2

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

Comments

0

Try running

npm uninstall -g create-react-app 

first and then installing desired version

4 Comments

What do you get if you type create-react-app --version
it is showing 1.5.2. however this is what it shows when i create an app Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts... + [email protected] + [email protected] + [email protected] added 1402 packages from 727 contributors and audited 888986 packages in 309.619s found 0 vulnerabilities
I have 1.5.2 installed on my machine as well and just tried create-react-app and can confirm I am getting the same App.js file as you are. I don't know why there is a discrepency between the two.
I found the solution.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.