从命令提示符运行时,jasmine-node显示错误

时间:2014-07-03 12:38:27

标签: node.js jasmine jasmine-node

使用以下命令安装jasmine-node:

sudo npm install jasmine-node -g

成功并显示:

/usr/bin/jasmine-node -> /usr/lib/node_modules/jasmine-node/bin/jasmine-node
jasmine-node@1.14.3 /usr/lib/node_modules/jasmine-node
├── underscore@1.6.0
├── mkdirp@0.3.5
├── walkdir@0.0.7
├── jasmine-reporters@2.0.0
├── coffee-script@1.7.1
├── requirejs@2.1.14
├── jasmine-growl-reporter@0.0.3 (growl@1.7.0)
└── gaze@0.3.4 (minimatch@0.2.14, fileset@0.1.5)

但是当我尝试运行此代码时:$ jasmine-node spec/jasmine-node它会显示如下错误:

/usr/lib/node_modules/jasmine-node/lib/jasmine-node/reporter.js:336
  jasmineNode.TeamcityReporter.prototype = new jasmine.TeamcityReporter;
                                           ^
TypeError: undefined is not a function
    at /usr/lib/node_modules/jasmine-node/lib/jasmine-node/reporter.js:336:44
    at Object.<anonymous> (/usr/lib/node_modules/jasmine-node/lib/jasmine-node/reporter.js:342:3)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/usr/lib/node_modules/jasmine-node/lib/jasmine-node/index.js:34:21)
    at Module._compile (module.js:456:26)

1 个答案:

答案 0 :(得分:13)

此问题与jasmine-reporters模块的上一版本相关,jasmine-node依赖于该模块。在修复问题之前,您可以执行的一种可能的解决方法是降级jasmine-node的版本,该版本取决于先前版本的jasmine-reporters

sudo npm install jasmine-node@1.14.2 -g

当前版本为1.14.3,因此它背后有一个版本。

此问题有一个漏洞: https://github.com/larrymyers/jasmine-reporters/issues/63