笔记分享:
下载依赖的时候记得先配置Alibaba的地址,这样可以提高下载的速度:
npm config set registry https://registry.npm.taobao.org
install的node_modules目录
npm install
1、npm项目初始化操作 使用命令npm init
E:\vscode\vs1010\npmdemo>npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
See `npm help init` for definitive documentation on these fields
and exactly what they do.
Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
package name: (npmdemo)
version: (1.0.0)
description:
entry point: (index.js)
test command:
git repository:
keywords:
author:
license: (ISC)
About to write to E:\vscode\vs1010\npmdemo\package.json:
{
"name": "npmdemo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
Is this OK? (yes) yes
项目初始化之后生成的文件:
这个文件类似于java的pom.xml文件
命令使用默认规则建包:
npm init -y
2、npm如何下载依赖
命令npm install 依赖名称
npm install jQuery