A way doing things only once?

Do I need to do the following steps to each new work?

npm init -y
npm install react@^17.0.0 react-dom@^17.0.0 --save

the following codes / steps are there:
https://www.tutorialspoint.com/reactjs/reactjs_creating_application.htm

isn`t there a more easier way to do it?
Specifically:
Is there a way to do these once and definitively without having doing them again and again?

I will appreciate your kind helps
thanks

1 Like

What IDE is being used and what kind of program are you writing?

I am a newbie starter with not much knowledge,
IDE is React? I googled whatever the IDE I may be using for React but did not found any logic thing, so I don`t know.

Maybe this may help you: I do blindly whatever the link that I wrote, says to me. So no real idea what IDE I am using.

I only know that I write those things in MsDos mode, and repeat them again and again, The tutorial sites that I tried, never say if it has to be done each time or not. Just this is really frustrating.

Sorry of not being able to give details with the correct technical stuff. Because I don`t know.
If you may find any answer to this repetition it will be very helpful. I will appreciate it a lot. Thanks

IDE stands for Integrated Development Environment and it is a application where you can write your code and has extra features like debugging, syntax highlighting, etc.

React is a JavaScript library.

If I had to guess you are probably using a code editor like visual studio code which is a popular choice for frontend developers.
Or maybe you are using another editor, like atom, brackets, sublime, etc.

Let’s break down what these commands are doing

npm init will create a package.json file for your new project.
This holds information about your project like, name, scripts(ex. command for running the project), the dependencies it uses, etc.

The -y flag (or you could use --yes flag) is used to create a starter package.json file with some basic information filled out for you. Without the use of that flag, then you will be walked through a prompt where you will need to fill out that information yourself.

This is what the default package.json looks like

{
  "name": "example-react-app",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

This line of code will install react and react-dom as a dev dependency

Now this is what your package.json file looks like

{
  "name": "example-react-app",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  }
}

Yes.

It looks like the article you are following wants you to set everything up from scractch.
But you don’t need to do that.

Most people now a days will use Vite

The command you would run is the following

npm create vite@latest name-of-app-goes-here -- --template react

You would find a folder you want to create your new project in.
Then replace name-of-app-goes-here with the name of your actual project

When you run that command, then everthing is setup for you.

Then you will need to change to that folder and then start the project

 npm install
 npm run dev

hope that helps

1 Like

Thanks a lot, this is a real answer

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.