Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why doesn't Npm.require work in server test code ? #181

Open
welelay opened this issue Jun 2, 2016 · 3 comments · May be fixed by #184
Open

Why doesn't Npm.require work in server test code ? #181

welelay opened this issue Jun 2, 2016 · 3 comments · May be fixed by #184

Comments

@welelay
Copy link

welelay commented Jun 2, 2016

I'm still trying to do a simple http.get in my test.

Here I try to make the server do the work:

    it("....", function() {
        return client
            .execute(function() {
                return computedEnpoint();
            }).then(function(url) {

                return server.execute(function() {
                    try {
                        console.log("Meteor is accessible:", Meteor.isServer);
                        // either of them fail
                        // var http = Npm.require("http");
                        // require("http");
                    } catch (e) {
                        console.error("E:", e);
                    }
                });

            });
     });

It fails to find Npm or require, but has Meteor and all my application's module :

Meteor is accessible: true
E: [ReferenceError: Npm is not defined]
E: [ReferenceError: require is not defined]

Is there a way to access base modules (not even npm packages) from server code ?

@apendua
Copy link
Member

apendua commented Jun 2, 2016

@welelay Are you using Meteor 1.3?

@welelay
Copy link
Author

welelay commented Jun 3, 2016

yes

@welelay
Copy link
Author

welelay commented Jun 3, 2016

following https://nodejs.org/api/vm.html#vm_example_running_an_http_server_within_a_vm
there may be a way to access require by adding it to plugins in backdoor.js.
I'll let you know...

@welelay welelay linked a pull request Jun 15, 2016 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants