hook.io icon indicating copy to clipboard operation
hook.io copied to clipboard

npm modules not installing / regression with npm auto-installs

Open Marak opened this issue 10 years ago • 15 comments

Since our move to the more restricted environment npm installs stopped working.

The issue is that npm needs to be required after the process is chroot in order to ensure the correct version of npm is installing dependencies ( inside the jail )

Should be resolved in the next day or so.

Marak avatar Sep 30 '15 09:09 Marak

Got this working locally.

Required that we build a new project for managing package installations ( https://github.com/bigcompany/hpm )

Should be deployed in the next day.

Marak avatar Oct 03 '15 05:10 Marak

auto-installs of modules are back online.

Still need to test more.

Marak avatar Oct 03 '15 12:10 Marak

@Marak would you mind sharing an example of how I can include a package from npmjs.com, which isn't in here: http://hook.io/packages/npm/installed

gavinengel avatar Oct 30 '15 16:10 gavinengel

@gavinengel - If you attempt to require a npm module in a Hook...it should just auto-install after the first run.

If you have any issues just let me know the package name and I will install myself.

Marak avatar Oct 31 '15 02:10 Marak

Hi Marak,

I'm new to hook.io

I'm trying to get send an email with mailgun-js but it seems not working.

module['exports'] = function echoHttp (hook) {
require('autoinstall');
var api_key = 'key-XXXXXXXXXXXXXXXXXXXXXXX';
var domain = 'mydomain.mailgun.org';
var mailgun = require('mailgun-js')({apiKey: api_key, domain: domain});

var data = {
  from: 'Excited User <[email protected]>',
  to: '[email protected]',
  subject: 'Hello',
  text: 'Testing some Mailgun awesomness!'
};

mailgun.messages().send(data, function (error, body) {
  console.log(body);
});

console.log(hook.params.sender)  
console.log(hook.params.recipient)
console.log(hook.params.subject)

hook.res.end(JSON.stringify({'msg':'OK'}, true, 2));
};

Can you please help? Thanks.

knguyen0105 avatar Nov 07 '15 02:11 knguyen0105

Auto install worked a few days ago but seems not to be working right now. I tried installing the spark package and it's stuck in pending.

monkbroc avatar Nov 07 '15 03:11 monkbroc

@knguyen0105 -

I went ahead and installed the mailgun-js package on hook.io for you.

I think its working now? http://hook.io/marak/mailgun/source

Please remove the autoinstall module. Based on the documentation I found at https://www.npmjs.com/package/autoinstall , you should not be using that tool on hook.io, ever.

Marak avatar Nov 07 '15 03:11 Marak

Also @knguyen0105 you should put your mailgun credentials in the environment https://hook.io/env and access them through hook.env otherwise anybody will be able to view them since the source code for your hook is publicly accessible.

monkbroc avatar Nov 07 '15 03:11 monkbroc

@monkbroc -

I went ahead and manually installed spark. Can you confirm it's working?

We have no automated testing around automatic npm installs right now. Will be working on that. Everything was working great until I jacked up security.

I'll take a look over the weekend and see if I can make some minor adjustments to improve visibility into package installation failures.

What I can also do is ensure that any manually installed deps / out of band dep installations will be accounted for in our database.

Marak avatar Nov 07 '15 03:11 Marak

For this hook:

module['exports'] = function particle (hook) {
  var Spark = require('spark');
}

I'm still getting a dependency error:


module.js:338
    throw err;
          ^
Cannot find module 'spark'

It looks like `spark` is a npm dependency. We are going to try to install it!
It should be ready in a few moments...

monkbroc avatar Nov 07 '15 03:11 monkbroc

@monkbroc Thank you very much for the tip. Mailgun credentials are stored in hook.env now!

@Marak The hook executes now till the end now. I can view log of sender and recipient but there is no mail...This is strange since I can run the same code on c9.io and got en email delivered.

knguyen0105 avatar Nov 07 '15 03:11 knguyen0105

Something appears wrong with auto-installs.

I'm looking into it right now.

Marak avatar Nov 07 '15 03:11 Marak

@monkbroc - spark is working now. sorry.

I think we might have roll back to [email protected] :-\

What I'm seeing on the servers is a massive increase in lag from npm@3 when attempting to install packages in a directory with lots of packages.

I have a feeling it's scanning the entire directory in a not so nice way.

Will see what I can do.

Marak avatar Nov 07 '15 03:11 Marak

A directory with lots of packages should be quite common on node projects!

Thanks @Marak the spark library works now.

monkbroc avatar Nov 07 '15 03:11 monkbroc

@Marak I still can't get mailgun-js to work. Is it possible that mailgun API drops requests from hook.io ?

knguyen0105 avatar Nov 09 '15 05:11 knguyen0105