In this blog, you will see how to set up development environment for React.
React
React is a declarative, efficient, and flexible JavaScript library for building user interfaces.
Prerequisites
Node.js
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js' package ecosystem, npm, is the largest ecosystem of open source libraries in the world.
NPM
Node Package Manager (NPM) is used to install the packages that you want to use, and provides a useful interface to work with them.
Install Node.js and NPM
Visual Studio Code
Install VS Code
Steps Involved
-
The following steps are needed to be followed to set up development environment for React.
-
Open Command Prompt.
-
Navigate to the respective folder to create the root folder for React.
cd D:\ReactJS
-
Create the root folder, as shown below.
mkdir helloworld
-
Run the following command in the console to create empty package.json file. Please refer this blog for more details.
npm init
-
Run the following command to install webpack bundler.
npm install webpack --save
-
Run the following command to install webpack-dev-server.
npm install webpack-dev-server --save
-
Run the following command to install react.
npm install react --save
-
Run the following command to install react-dom.
npm install react-dom --save
-
Run the following command to install babel plugins.
npm install babel-core
npm install babel-loader
npm install babel-preset-react
npm install babel-preset-es2015
-
Manually create the following files in the root folder helloworld.
index.html
App.jsx
main.js
webpack.config.js
-
Open the root folder in Visual Studio Code by running the following command.
code .
-
Open webpack.config.js file and add the below code snippet.
- var config = {
- entry: './main.js',
- output: {
- path: '/',
- filename: 'index.js',
- },
- devServer: {
- inline: true,
- port: 8080
- },
- module: {
- loaders: [
- {
- test: /\.jsx?$/,
- exclude: /node_modules/,
- loader: 'babel-loader',
- query: {
- presets: ['es2015', 'react']
- }
- }
- ]
- }
- }
- module.exports = config;


Alexander RyabuhaPosted Mar 30, 2017, 6:51 AM
Good article, but.. Could you please so kind to write, how to do it for Visual Studio 2017 and ASP.NET Core MVC (WebApi) project. It seems is not so obvious. Especially modularity and bundling.