NPM Global installation and local installation
npm install express # 本地安装npm install express -g # 全局安装
Local Installation
- Place the installation package under./node_modules (the directory where the NPM command is running), and if there is no Node_modules directory, the Node_modules directory is generated under the directory where the NPM command is currently executing.
Locally installed packages can be introduced via require ().
Global Installation
- Place the installation package under/usr/local or your node's installation directory.
Can be used directly on the command line.
If you want to have both features, you'll need to install it in two places or use NPM link.
The following are the meanings of the install suffix
npm install moduleName # 安装模块到项目目录下(不会将模块依赖写入devDependencies或dependencies 节点。)--save 将模块安装到项目目录下,并在package文件的dependencies节点写入依赖。-P, --save-prod:包会出现在你的dependencies。这是默认的,除非-D或-O存在。 -D, --save-dev:包会出现在你的devDependencies。-O, --save-optional:包会出现在你的optionalDependencies。--no-save:防止保存到dependencies。
NPM Install suffix