nodejs 开发之二 npm install 安装依赖包
1. 执行 npm install ,
C:\Program Files\nodejs\MyBook>npm install
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN mybook@1.0.0 No repository field.
up to date in 2.282s
found 0 vulnerabilities
2. 依赖包被安装到了 node_modules . 同时生成package-lock.json文件.
package-lock.jsaon 文件内容:
{
"name": "mybook",
"version": "1.0.0",
"lockfileVersion": 1
}
3. 安装项目需要的buffer包 npm install buffer 和 ignore
C:\Program Files\nodejs\MyBook>npm install buffer
npm WARN mybook@1.0.0 No repository field.
+ buffer@5.6.0
added 3 packages from 4 contributors and audited 3 packages in 5.157s
found 0 vulnerabilities
C:\Program Files\nodejs\MyBook>npm install ignore
npm WARN mybook@1.0.0 No repository field.
+ ignore@5.1.8
added 1 package from 1 contributor and audited 4 packages in 1.695s
found 0 vulnerabilities
自动生成了node_modules.
4.同时更新了: package-lock.json和Package.json文件:
{ "name": "mybook", "version": "1.0.0", "description": "My book shelf", "main": "index.js", "scripts": { "test": "node app.js" }, "author": "author", "license": "ISC", "dependencies": { "ignore": "^5.1.8" }, "devDependencies": { "buffer": "^5.6.0" } }
{ "name": "mybook", "version": "1.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { "base64-js": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==", "dev": true }, "buffer": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.6.0.tgz", "integrity": "sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw==", "dev": true, "requires": { "base64-js": "^1.0.2", "ieee754": "^1.1.4" } }, "ieee754": { "version": "1.1.13", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==", "dev": true }, "ignore": { "version": "5.1.8", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==" } } }