使用karma-browserify和browserify-shim时出错 [英] Error using karma-browserify with browserify-shim

查看:238
本文介绍了使用karma-browserify和browserify-shim时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将karma-browserify和browserify-shim一起使用,但没有成功。这是一个回购重现错误: https://github.com/pelizza/karma-browserify -shim
$ b

I'm trying to use karma-browserify together with browserify-shim with no success. Here is a repo to reproduce the error: https://github.com/pelizza/karma-browserify-shim

PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
TypeError: undefined is not an object (evaluating 'module.exports = ex')
at /var/folders/_0/ql88mbyd6v34qsmysr5kf4780000gn/T/e0c5e5ebe3f49930de3d988c7196737f.browserify:40308 <- bower_components/jquery/dist/jquery.js:9837:0

当与browserify捆绑在一起时,一切正常,似乎业力根本找不到减少的依赖关系当使用karma-browserify预处理文件时。

Everything works fine when bundling with browserify, by it seems that karma simply doesn't find shimmed dependencies when preprocessing files with karma-browserify.

我找不到这个问题,除了这个堆栈溢出,没有解决方案:当试图加载带有browserify-shim的模块时,karma-browserify会抛出错误

I couldn't find much about this problem, except this one at stack overflow, without a solution: karma-browserify throws error when trying to load modules shimmed with browserify-shim

推荐答案

找到解决方案:只要从karma配置文件中删除browserify-shim转换,如果它已被声明为package.json上的转换。

Found the solution: just remove the browserify-shim transform from the karma configuration file if it was already declared as a transform on package.json.

我已更新回购

I have updated the repo with this fix.

下面是关于这个问题的讨论: https://github.com/nikku/karma-browserify/issues/170#issuecomment-187372309

Here is the discussion about this issue: https://github.com/nikku/karma-browserify/issues/170#issuecomment-187372309

这篇关于使用karma-browserify和browserify-shim时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆