I’m trying to test an old package using meteor test-packages ./
, with the default driver test-in-browser
. I get the following warning from this code:
The jquery npm package could not be found in your node_modules directory.
Please run the following command to install it:
meteor npm install jquery
If you previously relied on a specific version of jquery, it may be important
to install that version; for example:
meteor npm install jquery@1.12.1
Indeed, Package.jquery
consists of {$: undefined, jQuery: undefined}
, suggesting that the Meteor package jquery@3.0.0
loaded, but the NPM peer dependency did not. This causes the Blaze backend to fail.
Here’s the relevant part of my package.json
:
Npm.depends({
//...
// Just needed for testing:
jquery: '3.6.0' // also tried '1.12.1' recommended by error message
});
Package.onTest(function (api) {
api.use('jquery@3.0.0', 'client');
api.use('blaze@2.5.0', 'client');
api.use('tinytest@1.1.0', ['server', 'client']);
api.use('test-helpers@1.2.0', ['server', 'client']);
//...
});
I don’t understand why Npm.depends
isn’t enough to load the jquery
NPM package. .npm/package/node_modules/jquery
exists and looks fine. I tried adding Npm.require('jquery')
to the test code to force it to load in browser, but that doesn’t seem to have an effect.
I figured that switching from jquery@3.0.0
to jquery@1.11.9
(which inlines a specific jquery
version) would fix the problem. Unfortunately, test-in-browser@1.3.0
depends on jquery@3.0.0
(not the usual jquery@1.11.9 || jquery@1.3.0
) so I can’t get that to work. meteor test-packages ./ --driver-package test-in-browser@1.2.0
and/or api.use('test-in-browser@1.2.0', ['server', 'client']);
doesn’t seem to work; it still uses test-in-browser@1.3.0
and thereby fails to resolve dependencies.
If relevant, I’m using Windows 10.
I guess the last thing to try is to copy the package into an application that has npm install jquery
. Rather annoyingly, this does seem to work.
Related threads: