0

I'm trying to work around this error in karma.

QUnit has comitted a fix for the error since v1.14.0, so I want to install qunit from git to work with karma-qunit.

npm rm qunitjs
npm i jquery/qunit

Then I run karma and I get an error, even though ./node_modules/qunitjs is present with a package.json file:

$ ./node_modules/karma/bin/karma start

module.js:340
    throw err;
    ^
Error: Cannot find module 'qunitjs'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.require.resolve (module.js:384:19)
    at initQUnit (/home/nik/src/dmt/node_modules/karma-qunit/lib/index.js:7:39)
    at Array.invoke [as 0] (/home/nik/src/dmt/node_modules/karma/node_modules/di/lib/injector.js:75:15)
    at get (/home/nik/src/dmt/node_modules/karma/node_modules/di/lib/injector.js:48:43)
    at /home/nik/src/dmt/node_modules/karma/lib/server.js:31:14
    at Array.forEach (native)
    at start (/home/nik/src/dmt/node_modules/karma/lib/server.js:30:21)
    at invoke (/home/nik/src/dmt/node_modules/karma/node_modules/di/lib/injector.js:75:15)
    at Object.exports.start (/home/nik/src/dmt/node_modules/karma/lib/server.js:306:12)

The error doesn't occur when installing qunit with npm install qunitjs. Anyone know what's going on?

I'm using npm 1.4.16 and node 0.10.25.

user2226755
  • 12,494
  • 5
  • 50
  • 73
nnyby
  • 4,748
  • 10
  • 49
  • 105
  • quick fix: `npm rm qunitjs` `npm install github.com/jquery/qunit` npm knows how to use github. you can also specify branches, commits, tags with the same url syntax as github. – generalhenry Jun 26 '14 at 21:08
  • @generalhenry that's exactly what I did. `npm i jquery/qunit` is a shortcut for `npm install github.com/jquery/qunit`. Have you tried using karma with qunit from github? – nnyby Jun 27 '14 at 15:29

2 Answers2

2

Make this folders tree :

./node_modules/
    ./node_modules/
        ./qunitjs/
    ./karma/

Or use npm in karma folder './node_modules/karma/bin/' or './node_modules/karma/'.

cd /home/nik/src/dmt/node_modules/karma/bin/
npm i jquery/qunit
user2226755
  • 12,494
  • 5
  • 50
  • 73
0

Finally worked this issue out. Turns out I had to install qunitjs globally before it worked.

npm install -g qunitjs

Don't like the solution as it will break module dependancy (for other developers), but seems the only way it worked for me.

I do have Karma installed (via npm) globally too, so maybe that's why.

Guy Park
  • 959
  • 12
  • 25