1 |
On 09/17/2015 10:03 AM, Alan McKinnon wrote: |
2 |
> Anyone here familiar with driving nodejs and npm? |
3 |
> |
4 |
> I'm trying to write an ebuild for a musicbrainz mirror server and "npm |
5 |
> install" keeps erroring out with one of two errors: |
6 |
> |
7 |
> 1. The install does finish but npm doesn't get around to exiting, |
8 |
> verified by stopping the emerge, running npm install manually and seeing |
9 |
> that it does nothing. When it stalls strace shows the last call was |
10 |
> (poll,<number> ), which implies a race condition. |
11 |
> |
12 |
> 2. More and more often now I get the dreaded "npm: ERR! cb() never |
13 |
> called!" error message which Google and stackoverflow say has been an |
14 |
> ongoing issue for 3 years now. If I keep retrying it eventually |
15 |
> succeeds, implying a race condition of some sort. |
16 |
> |
17 |
|
18 |
I went through this wonderful experience a few weeks ago. You're not |
19 |
allowed to access the network in src_prepare, so that might be |
20 |
contributing to your weirdness. I came up with two options: |
21 |
|
22 |
1) Run `npm install` on your dev machine, and then package up the result |
23 |
as a tarball. Generate the manifest from the tarball, and then in your |
24 |
src_install, just copy stuff over. |
25 |
|
26 |
src_install(){ |
27 |
local npm_module_dir="/usr/$(get_libdir)/node/${PN}" |
28 |
insinto "${npm_module_dir}" |
29 |
doins -r whatever |
30 |
... |
31 |
} |
32 |
|
33 |
|
34 |
This is the lazy way, but avoids you having to package 1,000 other |
35 |
things all written by people who just "learned to code" by googling HOW |
36 |
DO I HTML5. |
37 |
|
38 |
2) The right way to do it is to use an eclass and install all of the |
39 |
dependencies using separate packages. As you can imagine, this is a |
40 |
nightmare if you have more than a few dependencies (looks like you do). |
41 |
|
42 |
I started an eclass for npm packages. I left the overlay here: |
43 |
|
44 |
https://github.com/orlitzky/npm |
45 |
|
46 |
but no one else seemed interested in having it in-tree, and the whole |
47 |
ecosystem is kind of scary to me anyway. |
48 |
|
49 |
So, for the large package I need, I'm doing it the lazy way: npm install |
50 |
on my machine, and make an ebuild for the resulting huge tarball. |