meteorhacks / npm

Complete NPM integration for Meteor
http://meteorhacks.com/complete-npm-integration-for-meteor.html
MIT License
508 stars 43 forks source link

Object> has no method 'npmRequire with tiny test #82

Open dcsan opened 9 years ago

dcsan commented 9 years ago

I have a package that uses this

in running it with tinytest, I got the errors below.

fwiw the app itself runs fine, its just trying to write/run tests which fails :/

The environment is identical for test and normal app execution (same Package.on_use code)

I checked another related thread about startup #59 but that doesn't seem relevant in this case.

TypeError: Object #<Object> has no method 'npmRequire'
    at Object.ExtData.readSheet (packages/dcsan:extdata/lib/ExtData.coffee:44:30)
    at [object Object].Tiles.reload (packages/local-test:chatu:chapters/collections/Tiles.coffee:5:18)
    at packages/local-test:chatu:chapters/tests/chapters_tests.coffee:4:11
    at Object.Meteor.startup (packages/meteor/startup_server.js:6:1)
    at Package (packages/local-test:chatu:chapters/tests/chapters_tests.coffee:3:10)
    at [object Object].func (packages/tinytest/tinytest.js:636:1)
    at packages/tinytest/tinytest.js:406:1
    at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
    at packages/meteor/timers.js:6:1
    at runWithEnvironment (packages/meteor/dynamics_nodejs.js:108:1)
dcsan commented 9 years ago

small point is that one package which I am writing tests for, in turn uses another package, which uses the npm:hack. However, adding

    api.use([
...
      'meteorhacks:npm',

to BOTH packages in the hierarchy, i still can't solve the problem.

has anyone got this to work with tinytests, or am i wasting time here?

rapito commented 9 years ago

+1 I'm getting the same problem.

ssteinerx commented 9 years ago

+1, same thing. Server only file, even tried wrapping like this:

Meteor.startup(function () {
  var request = Meteor.npmRequire('request');
});

This IS in:

Package.on_test(function (api){
  ...
  api.use('tinytest');
  api.use('meteorhacks:npm');
 ...
});

packages.json does not seem to be around anywhere (it's in the root of the main project, not in any package), and trying to add it as an asset with:

api.addFiles('packages.json', 'server', {
     isAsset: true
  });

doesn't help as the error message indicates that it can't find packages.json.

Help?

huevoncito commented 8 years ago

+1. Anybody have an update on this?