gpt4 book ai didi

node.js - npm 依赖项安装,困惑

转载 作者:太空宇宙 更新时间:2023-11-03 21:59:19 25 4
gpt4 key购买 nike

我安装了两套node.js/npm,一套是1.4.28,一套是3.1.0

通过使用包含以下内容的 package.json 文件部署相同的应用程序:

    {
"name": "server",
"version": "0.0.1",
"description": "js server",
"dependencies": {
"async": "^1.3.0",
"aws-sdk": "^2.1.36",
"body-parser": "^1.13.2",
"ejs": "^2.3.2",
"express": "^4.13.1",
"generic-pool": "^2.2.0",
"multer": "^0.1.8",
"mysql": "^2.7.0",
"node-uuid": "^1.4.3",
"nodemailer": "^1.4.0",
"nodemailer-smtp-transport": "^1.0.3",
"password-hash-and-salt": "^0.1.2",
"pm2": "^0.14.3",
"redis": "^0.12.1",
"redis-sessions": "^0.3.9",
"request": "^2.58.0",
"socket.io": "^1.3.5",
"winston": "^1.0.1",
"yauzl": "^2.3.1"
}
}

在版本 1.4.28 上,在没有任何 node_modules 目录的全新安装上运行 npm install 后,如果填充了正确的所需模块:

enter image description here

在 3.1.0 版本上,我得到了大量在我看来不需要的从属依赖项:

enter image description here

所以任何人都可以向我解释发生了什么事以及为什么我让所有这些部门都参与其中?我也尝试过在 npm 上使用 --product ,但没有成功......

非常感谢!

最佳答案

这是新的 npm 3.* 功能。来自 npm blog :

With npm@3, your node_modules directory will be a lot flatter. All of your dependencies and most of your subdependencies (and (sub)+dependencies) will be sitting next to each other at the top level. Only when there are conflicts will modules be installed at deeper levels. This should make things a lot easier for Windows users.

关于node.js - npm 依赖项安装,困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31317925/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com