npm 依赖安装,困惑 [英] npm dependancies installation, confused
问题描述
我安装了两个 node.js/npm ,一个是 1.4.28,一个是 3.1.0
I've two installations of node.js/npm , one is 1.4.28 and one is 3.1.0
通过使用包含以下内容的 package.json 文件部署相同的应用程序:
by deploying the same app with the package.json file containing:
{
"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 后,如果填充了正确的必需模块:
on the version 1.4.28 , after running npm install on a fresh installation without any node_modules directory, if fills with the correct required modules:
在 3.1.0 版本中,我得到了大量我认为不需要的子依赖项:
while on the version 3.1.0 I get tons of subdependancies that should not been needed in my opinion:
所以任何人都可以向我解释发生了什么以及为什么我将所有这些 deps 拉进来?我也试过 --production what 在 npm 上没有成功...
So anyone could explain me what's going on and why I get all those deps pulled in ? I've also tried with --production what on npm with no success...
非常感谢!
推荐答案
这是 npm 3.* 的新功能.来自 npm 博客:
It's new npm 3.* feature. From npm blog:
使用 npm@3,您的 node_modules 目录会更加平坦.所有的您的依赖项和大多数子依赖项(和(sub)+dependencies) 将在顶部彼此相邻等级.只有当有冲突时才会安装模块更深层次.对于 Windows 用户来说,这应该会让事情变得更容易.
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.
这篇关于npm 依赖安装,困惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!