yudi
yudi

Reputation: 91

Why we have to install NodeJS for ReactJS

I'm a beginner in ReactJS also for NodeJS. I would love to know why we have to install NodeJS run ReactJS application as ReactJS is client-side scripting.

Upvotes: 7

Views: 9041

Answers (3)

Sina Salmani
Sina Salmani

Reputation: 1

Of course, you don't have to. When you are in the development step, you can install it for package management. Only webpack is needed to bundle, compile, transpile the code.

Upvotes: 0

Jonny Lin
Jonny Lin

Reputation: 777

The other answer is incorrect. You don't NEED Node.js, in fact you could create a project without running a single npm command. Just follow this guide.

The main reason, as pointed out in the article, is:

  1. Easy package management. This means you can upgrade the package easily later on
  2. JSX is the templating language that makes it way easier to write components: <h1>Hello Word</h1> reads so much better than React.createElement('h1', null, 'Hello World')
  3. Managing module imports, as opposed to having global variables around everywhere, it's great to have encapsulation and import modules as needed.
  4. Build step and workflow. For a modern project, you will need tools to minify your code, cache busting, transpiling (writing pure javascript for old browser is a pain and you really shouldn't do it manually), the list goes on and on.

Upvotes: 13

Michele Federici
Michele Federici

Reputation: 1835

Because almost all the JavaScript libraries/frameworks are using the Node Package Manager (NPM), that makes much more convenient to manage JavaScript dependencies in general, both client-side and server-side.

Edit: It's not really technically necessary, but using a package manager is the best practice for managing dependencies and sub-dependencies.

Upvotes: 4

Related Questions