在我正在进行的项目中,我们使用 Karma 测试运行器,并且 karma-phantomjs-launcher帮助我们使用 PhantomJS 运行测试。最近,我们发现 PhantomJS 版本作为对 karma-phantomjs-launcher 的依赖项被拉下 1.9.8
有一些问题使我们的测试失败。幸运的是,karma-phantomjs-launcher 允许我们设置 PHANTOMJS_BIN
环境变量指向一个替代的 PhantomJS 二进制文件来代替使用,这使得升级到 2.0.0
相当简单。
这一切都很好,但是当我们的持续集成环境尝试构建我们的项目时,它仍然会拉下 PhantomJS 1.9.8
执行 npm install
时的二进制文件, 因为它需要安装 karma-phantomjs-launcher
这取决于 PhantomJS 1.9.8
.
由于我们的构建服务器已配置为使用 2.0.0
我们给它的二进制文件,真的没有必要下载 1.9.8
二进制文件,我希望它尽可能不这样做。
那么有什么方法可以配置我的 package.json 来告诉 karma-phantomjs-launcher
它不需要拉下它的 PhantomJS 1.9.8
依赖?
最佳答案
使用没有依赖的模块:
phantomjs package downloads PhantomJS from the third-party website. While this download can be prevented by making sure that you have correct PhantomJS version in the PATH, this is not always practical.
This package removes phantomjs from dependencies and requires you to set the path to PhantomJS explicitly.
或者从默认的 package.json 中移除它。例如,在 Linux shell 上:
cd node_modules/karma-phantomjs-launcher
vi package.json
移除dependencies
声明:
"dependencies": {
"phantomjs": "~1.9"
},
引用资料
关于dependencies - 排除 npm 模块依赖?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31616837/