Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
`qunit --require` does not find local module if qunit is globally installed #1372
Tell us about your runtime:
What are you trying to do?
What actually happened?
What did you expect to happen?
Good question, @platinumazure. I hadn't tried those variations.
I tried all globally first:
I got the same error.
Then I tried installing
and it worked!
So good news! I'm unblocked. But is this expected behavior?
Without QUnit doing some coding
I'm not able to get it work with a pure local install:
~/classes/vanilla-web/coin-toss > npm ls -g esm /Users/marty/.node/lib └── (empty) ~/classes/vanilla-web/coin-toss > npm ls -g qunit /Users/marty/.node/lib └── (empty) ~/classes/vanilla-web/coin-toss > npm ls esm qunit /Users/marty/classes/vanilla-web/coin-toss ├── email@example.com └── firstname.lastname@example.org ~/classes/vanilla-web/coin-toss > npx qunit --require esm test/tests.js TAP version 13 not ok 1 test/tests.js > Failed to load the test file with error: /Users/marty/classes/vanilla-web/coin-toss/test/tests.js:2 import getHeadsOrTails from '../src/get-heads-or-tails.js'; ^^^^^^^^^^^^^^^ SyntaxError: Unexpected identifier at new Script (vm.js:74:7) at createScript (vm.js:246:10) at Object.runInThisContext (vm.js:298:10) at Module._compile (internal/modules/cjs/loader.js:670:28) at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10) at Module.load (internal/modules/cjs/loader.js:612:32) at tryModuleLoad (internal/modules/cjs/loader.js:551:12) at Function.Module._load (internal/modules/cjs/loader.js:543:3) at Module.require (internal/modules/cjs/loader.js:650:17) at require (internal/modules/cjs/helpers.js:20:18) --- message: "should be able to load file" severity: failed actual: false expected: true stack: at Object.<anonymous> (/Users/marty/classes/vanilla-web/coin-toss/node_modules/qunit/src/cli/run.js:60:13) ... 1..1 # pass 0 # skip 0 # todo 0 # fail 1
I think a locally installed
However, the case of globally installing qunit and finding a local module seems one I expect to work.
I do generally recommend for project management to keep versioning of dependencies local to a project (and run via
I've updated the task summary to reflect that use case to distinguish it from the case where both are local, which appears to work.