Classification of packages
Project package: The packages installed in the node_modules directory of the project are all project packages. Project packages can also be subdivided into two categories:
Development dependency packages: The packages recorded in the devDependencies node will only be used during development.
Core dependency package: The package recorded in the dependencies node will be used during development and after the project is launched.
Global package: When executing the
npm install
command, if the-g
parameter is provided, the package will be installed as a global package. Global packages are installed by default in the C:\Users\User Directory\AppDate\roaming\npm\node_modules directory.Installation command:
npm i package name -g
; uninstall command:npm uninstall package name -g
Only tool-like packages are necessary for global installation because they provide useful terminal commands. To determine whether a package needs to be installed globally before it can be used, you can refer to the official instructions for use.
i5ting_toc
i5ting_toc is a small tool that can convert md documents into html pages, using steps:
1
2npm install -g i5ting_toc
i5ting_toc -f path to md file to convert -o
Canonical package structure
A standard package, the composition structure must meet 3 requirements:
Packages must exist as separate directories
The package management configuration file package.json must be included in the top-level directory of the package
Package.json must contain three properties: name (package name), version (version number) and main (package entry). When the outside world imports a package through
require()
, it imports the file pointed to by the main attribute.