package.jsonImportant Notes
package.json is a file that is required to create any node.js project.
Because in the package.json file, there is a detailed project description,
include:
(1) Project name: name
(2) Version: version
(3) Dependent files: dependencies, etc..
1. Create node.js project steps
(1) Create a package.json file
(2) Run npm install to create the node_modules folder
(3) Write node.js files and use corresponding external modules
2. Create package.json step by step
npm init
3. Automatically create package.json
npm init --yes
4. Use npm to operate node
node app.js
With package.json, what we do is a project
Therefore, you can use npm to operate the object project. In package.json, the script key can directly operate the project
5. Add dependencies
When using npm install to install a package file, if you add the --save command, npm will add the corresponding package file name to the dependencies of package.json
6. devDependencies
The difference between --save and --save-dev --save is to add the name of the package to dependencies, --save-dev is to add the name of the package to devDependencies
7. devDependencies 和 dependencies
Dependencies depend on the packages and modules in the code
In devDependencies, there are gulp webpack grunt, etc. that depend on project management tools