1、创建文件夹npmdemo
image.png

2、项目初始化
#建立一个空文件夹,在命令提示符进入该文件夹执行命令初始化 ,此命令可设置项目名称等信息。

| PS E:\1010\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:\1010\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
npm notice
npm notice New minor version of npm available! 7.21.1 -> 7.23.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.23.0
npm notice Run npm install -g npm@7.23.0 to update!
npm notice
PS E:\1010\npmdemo> | | —- |

如果想直接生成 package.json 文件,那么可以使用命令
npm init -y