On 09/17/2015 10:03 AM, Alan McKinnon wrote:
> Anyone here familiar with driving nodejs and npm?
> 
> I'm trying to write an ebuild for a musicbrainz mirror server and "npm
> install" keeps erroring out with one of two errors:
> 
> 1. The install does finish but npm doesn't get around to exiting,
> verified by stopping the emerge, running npm install manually and seeing
> that it does nothing. When it stalls strace shows the last call was
> (poll,<number>    ), which implies a race condition.
> 
> 2. More and more often now I get the dreaded "npm: ERR! cb() never
> called!" error message which Google and stackoverflow say has been an
> ongoing issue for 3 years now. If I keep retrying it eventually
> succeeds, implying a race condition of some sort.
> 

I went through this wonderful experience a few weeks ago. You're not
allowed to access the network in src_prepare, so that might be
contributing to your weirdness. I came up with two options:

1) Run `npm install` on your dev machine, and then package up the result
as a tarball. Generate the manifest from the tarball, and then in your
src_install, just copy stuff over.

  src_install(){
      local npm_module_dir="/usr/$(get_libdir)/node/${PN}"
      insinto "${npm_module_dir}"
      doins -r whatever
      ...
  }


This is the lazy way, but avoids you having to package 1,000 other
things all written by people who just "learned to code" by googling HOW
DO I HTML5.

2) The right way to do it is to use an eclass and install all of the
dependencies using separate packages. As you can imagine, this is a
nightmare if you have more than a few dependencies (looks like you do).

I started an eclass for npm packages. I left the overlay here:

  https://github.com/orlitzky/npm

but no one else seemed interested in having it in-tree, and the whole
ecosystem is kind of scary to me anyway.

So, for the large package I need, I'm doing it the lazy way: npm install
on my machine, and make an ebuild for the resulting huge tarball.


Reply via email to