jasmine-node shows error when ran from command pro

2019-04-12 08:00发布

问题:

Installed jasmine-node using this:

sudo npm install jasmine-node -g

It is successful and shows:

/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)

But when I try to run this: $ jasmine-node spec/ or jasmine-node it shows the error like this:

/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:

The issue is relevant to last version of jasmine-reporters module, on which jasmine-node depends on. One of possible workarounds you can do until issue will be fixed is to downgrade version of jasmine-node in which it depends on previous version of jasmine-reporters.

sudo npm install jasmine-node@1.14.2 -g

Current version is 1.14.3, so it is one version behind.

There is an open bug for this issue: https://github.com/larrymyers/jasmine-reporters/issues/63