First, react experience of the NODEJS environment construction

Source: Internet
Author: User

First, Nodejs installation

I have related articles in my blog and I will not repeat them here.

Second, the relevant module installation

Some related modules need to be installed when using react:

1, Babel

  NPM Install Babel-g--save-dev

(where--save-dev indicates that the Babel module is placed under devdependencies of the current project's Package.json file, representing the dependent module of the current development environment.)

--save indicates that the Babel module is placed under dependencies of the current project's Package.json file, representing the dependent module of the current running environment. )

The main role of Babel is to convert the associated ES6 syntax in the code to the ES5 accepted by most browsers today.

2, Webpack

  NPM Install Webpack-g--save-dev

Webpack main role is to package the current project resources, generate a JS file for the front page to introduce loading.

3, Webpack-dev-server

  NPM Install Webpack-dev-server-g--save-dev

The primary role of Webpack-dev-server is to create servers.

Specifically, to understand the module installation related methods, please visit: Http://javascript.ruanyifeng.com/nodejs/npm.html#toc8

Third, create the project root file Package.json

This file mainly statistics on the current project's various information, such as project name, version, dependency, development environment dependency and so on.

Create this file with NPM init, then follow the prompts to fill in the relevant content. (If you don't want to fill it out, you can use NPM init--yes or NPM init--y), and then continue adding changes in Package.json.

{  "Name": "Apptest",//project name"Version": "1.0.0",//project current version"Main": "Main.js",//The entry file when loading the module, all the modules eventually converge here ."Dependencies": {//Dependency module at Project runtime
}, "Devdependencies": {//modules that are dependent on project development

}, "Scripts": {//write execute NPM Run < command >,If running NPM [run] start is equivalent to performing a webpack-dev-server--hot
"Start": "Webpack-dev-server--hot"
},
"keywords": [],
"Author": "",
" License": "ISC",
" description": "",
}

Package.json the meaning of the items in the document, please visit: http://javascript.ruanyifeng.com/nodejs/packagejson.html

Iv. adding related plugins

1, react related plug-in

①npm Install react--save

React's core module.

②npm Install react-dom--save

The react is used to render the created virtual component onto the DOM.

2. Babel related plugins

NPM Install Babel-core

NPM Install Babel-loader

NPM Install Babel-preset-react

NPM Install Babel-preset-es2015

These modules deal primarily with ES6 compatibility issues.

Follow-up will be updated, please pay attention.

First, react experience of the NODEJS environment construction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.