How to install qunitjs with git on Karma's?

1k views Asked by At

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.

2

There are 2 answers

0
user2226755 On BEST ANSWER

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
0
Guy Park On

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.