【发布时间】:2014-06-09 19:30:09
【问题描述】:
通常我可以在 Google 上发现我遇到的任何问题,但在这种情况下,我完全不知道要搜索什么。
我的父模块有两个依赖:
"grunt-contrib-uglify": "~0.2.7""node-snapshot": "~0.3.22"
但是,当node-snapshot 也依赖于~0.2.7 时,它不会安装在node-snapshot 的node_modules 目录中。我的 Snapshot 应用程序通过 Travis 自动部署到 Heroku,因此具有:
"scripts": {
"test": "grunt test",
"start": "node example/server/default.js",
"postinstall": "node_modules/grunt-cli/bin/grunt build:production"
}
在我的父模块 (npm install node-snapshot) 中安装后也会调用它,但由于父模块和子模块都依赖 grunt-contrib-uglify ~0.2.7 而失败:
>> Local Npm module "grunt-contrib-uglify" not found. Is it installed?
Warning: Task "uglify" not found. Use --force to continue.
如果父模块依赖于不同版本的grunt-contrib-uglify,那么node-snapshot 成功地在其node_modules 目录中安装grunt-contrib-uglify,并且一切都是tickety-boo。
我将如何解决这个问题?对我来说很明显,所有子模块都需要自己的安装,即使父模块具有相同的模块,因为相对而言,子模块 (node-snapshot) 无法找到其依赖项之一。
【问题讨论】:
-
即使省略路径也不能解决问题:
grunt build:production.