In the front-end development process, Node.js will use the NPM manager for package management. The Node Package Manager (NPM) package manager is mainly used for downloading, installing, and managing third-party modules. It has powerful third-party resources and is of self-evident importance.
First, NPM installation
NPM installation steps are very simple, just input a command line in the terminal: apt-get isntall NPM enter, you can install.
After installing NPM, run the command: NPM serve on the terminal and press Enter to check whether the installation is successful. If the following message is displayed, the installation is successful:
ChendeMac$ npm -v
6.13.4
ChegdeMac$ npm serve
Usage: npm <command>
where <command> is one of:
access, adduser, audit, bin, bugs, c, cache, ci, cit,
clean-install, clean-install-test, completion, config,
create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
edit, explore, fund, get, help, help-search, hook, i, init,
install, install-ci-test, install-test, it, link, list, ln,
login, logout, ls, org, outdated, owner, pack, ping, prefix,
profile, prune, publish, rb, rebuild, repo, restart, root,
run, run-script, s, se, search, set, shrinkwrap, star,
stars, start, stop, t, team, test, token, tst, un,
uninstall, unpublish, unstar, up, update, v, version, view,
whoami
npm <command> -h quick help on <command>
npm -l display full usage info
npm help <term> search for help on <term>
npm help npm involved overview
Specify configs in the ini-formatted file:
/Users/Cheng/.npmrc
or on the command line via: npm <command> –key value
Config info can be viewed via: npm help config
[email protected] / usr/loal/lib/node_modules/NPM
ChenZeMacheng$ npm -v
6.13.4
ChenZeMac Cheng$ cnpm serve
Usage: npm <command>
where <command> is one of:
access, adduser, audit, bin, bugs, c, cache, ci, cit,
clean-install, clean-install-test, completion, config,
create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
edit, explore, fund, get, help, help-search, hook, i, init,
install, install-ci-test, install-test, it, link, list, ln,
login, logout, ls, org, outdated, owner, pack, ping, prefix,
profile, prune, publish, rb, rebuild, repo, restart, root,
run, run-script, s, se, search, set, shrinkwrap, star,
stars, start, stop, t, team, test, token, tst, un,
uninstall, unpublish, unstar, up, update, v, version, view,
whoami
npm <command> -h quick help on <command>
npm -l display full usage info
npm help <term> search for help on <term>
npm help npm involved overview
Specify configs in the ini-formatted file:
/Users/Cheng/.cnpmrc
or on the command line via: npm <command> –key value
Config info can be viewed via: npm help config
[email protected] / ur/loal/lib/node_moules/CNPM/node_modules/NPM
Second, the use of NPM
1. NPM mode
NPM has two modes: global mode and local mode.
NPM defaults to local mode, which only works in the current working directory. Anything done in local mode does not affect node.js code elsewhere.
NPM global mode, as the name implies, is used for all node.js project code on the computer. Operating in global mode requires only one operation to enable all Node.js projects on the computer, so pay attention to this mode.
2, NPM common command
NPM install Installs the module
NPM uninstall Uninstalls modules
NPM remove Removes a module
NPM update Updates the module
NPM outdated checks whether the module is outdated
NPM ls View installed modules
NPM help Displays detailed help for a command line
NPM root View the installation path of the package
NPM config Manages the NPM configuration path
NPM cache Indicates the cache of the management module
NPM start Starts the module
NPM stop Stops the module
NPM restart Restarts the module
NPM test Tests the module
NPM version Displays the module version
NPM view Displays module registration information
NPM adduser Login
NPM publish publish module
NPM Access sets the level of access on published packages
The above is all the content of this chapter. Welcome to pay attention to the wechat public account of Sanzhan “iOS development by Sanzhan”, and the Sina Weibo account of Sanzhan “Sanzhan 666”, welcome to pay attention to it!