Learning Redux
上QQ阅读APP看书,第一时间看更新

Initializing the project

When creating a new project, we will first need to create a package.json file. The easiest way to do this is to run the following command:

npm init

This command will ask you a few questions regarding the project name, version, and so on. Change the entry point to src/index.js. For everything else, we can simply press Enter. We can change these values in the generated package.json file later. If you already have an existing project, we can change the entry point by adjusting the main property in the package.json file.

For a complete list of configuration options in the package.json file, check out the NPM documentation at https://docs.npmjs.com/files/package.json.

Afterwards, create a src folder to store your JavaScript code in:

mkdir src

It is always a good idea to keep source files separate from your project configuration. Doing this ensures that when your project grows, the root folder structure does not get too messy. It also makes it easier to configure other tools, for example, configuring babel-watch to reload on file changes in the src/ directory only.