NPM 不安装模块依赖项 [英] NPM doesn't install module dependencies
问题描述
这是我包含在父项目中的模块的package.json
:
This is my package.json
for the module that I'm including in the parent project:
{
"version": "0.0.1",
"name": "module-name",
"dependencies": {
"express": "3.3.4",
"grunt": "0.4.1",
"grunt-contrib-compass": "0.4.0",
"grunt-contrib-copy": "0.4.1",
"grunt-contrib-cssmin": "0.4.1",
"grunt-contrib-jshint": "0.6.3",
"grunt-contrib-requirejs": "0.4.1",
"grunt-contrib-uglify": "0.2.2",
"grunt-contrib-watch": "0.5.1",
"grunt-express-server": "0.4.1",
"grunt-karma": "0.4.5",
"grunt-regex-replace": "0.2.5",
"request": "2.25.0"
},
"scripts": {
"postinstall": "grunt install"
}
}
需要注意的一点是,这个模块包含在一个私有仓库中,我将它包含在父 package.json
中,例如:"module-name": "git+ssh://git@myserver:user/module-name.git"
One thing to note is that this module is contained in a private repo and I include it in the parent package.json
like: "module-name": "git+ssh://git@myserver:user/module-name.git"
推荐答案
看起来您遇到了一个已经存在很长时间并且还没有解决方案的错误.npm 存储库中有几个针对此案例的未解决问题:
It looks like you hit a bug that has existed for quite a while and doesn't have solution yet. There are several open issues for this case in the npm repository:
- npm install 应该递归地检查/安装依赖项 https://github.com/npm/npm/问题/1341(已关闭)
- 本地私有模块依赖 https://github.com/npm/npm/issues/2442(关闭)
- npm install should recursively check/install dependencies https://github.com/npm/npm/issues/1341 (closed)
- local private module dependencies https://github.com/npm/npm/issues/2442 (closed)
在第一个中,人们列出了您可以尝试的几种解决方法.
In the first one people list several workarounds that you may try.
另一种解决方案可能是(有点hackish)将依赖项明确列为第一级依赖项.这需要您维护列表,但实际上很少这样做.
An alternative solution may be (a little hackish) to explicitly list the dependencies as first level dependents. This requires you to maintain the list but practically it has to be done very infrequently.
这篇关于NPM 不安装模块依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!