node.js 通过 NPM 安装 MySQL

创建 test 文件夹:

mkdir test

然后进入到该文件夹下:

cd test

快速创建 package.json文件

npm init -y

该指令输出结果为:

Wrote to /Users/muzico/Documents/Project/node_js/demo/20180827/test/package.json:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

安装 MySQL:

npm install mysql

该指令输出结果为:

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN test@1.0.0 No description
npm WARN test@1.0.0 No repository field.

+ mysql@2.16.0
added 11 packages from 15 contributors in 1.863s
[+] no known vulnerabilities found [13 packages audited]