Like here
npm install -g create-react-app
create-react-app my-app
cd my-app
npm start
Why do we use npm and node . Why can't we use just a single cdn file ?
Like here
npm install -g create-react-app
create-react-app my-app
cd my-app
npm start
Why do we use npm and node . Why can't we use just a single cdn file ?
ReactJS uses Node.js, a JavaScript runtime, to build your JavaScript code.
Basically, the ReactJS is a JavaScript framework which needs the help of node js and npm(Package manager) to tell the native side(Android/iOS) that these are packages I need to run my app. And it adds all the dependencies needed to run the app.
You can just use a simple html/cdn setup. The problem comes when you start having to manage a lot of dependencies, which inevitably happens. You'll eventually want to divide your project among several files to help organize it. All this becomes difficult without tools like NPM,Webpack, etc. This is especially true if you are working in a group where you want to communicate to strangers what is needed to build you program.
If you're just learning React or building a quick, small project the CND is fine, but eventually you'll need a more robust way to deal with this and npm works well.
Nodejs is not compulsorily required to run react code or build react apps. It is required to use so many tools that makes react development easy and avoid doing things manually. For example - Tool chain create-react-app is a npm package(which in turn require nodejs to be installed on system) which setup development environment and makes so many things already configured.