GNU bug report logs - #51838
[PATCH 00/11] guix: node-build-system: Support compiling add-ons with node-gyp.

Previous Next

Package: guix-patches;

Reported by: Philip McGrath <philip <at> philipmcgrath.com>

Date: Sun, 14 Nov 2021 12:43:01 UTC

Severity: normal

Tags: patch

Done: Liliana Marie Prikler <liliana.prikler <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Pierre Langlois <pierre.langlois <at> gmx.com>
To: Philip McGrath <philip <at> philipmcgrath.com>
Cc: 51838 <at> debbugs.gnu.org
Subject: [bug#51838] [PATCH v3 04/43] gnu: node: Add an npmrc file to set nodedir.
Date: Sun, 12 Dec 2021 15:19:39 +0000
[Message part 1 (text/plain, inline)]
Philip McGrath <philip <at> philipmcgrath.com> writes:

> * gnu/packages/node.scm (node, node-lts)[arguments]: Add a phase
> 'install-npmrc to create a "built-in" npmrc file that configures
> "nodedir" to point to the output store path.
> (libnode)[arguments]: Delete the 'install-npmrc phase.
> ---
>  gnu/packages/node.scm | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/gnu/packages/node.scm b/gnu/packages/node.scm
> index a57a74fb81..0f67fe79c2 100644
> --- a/gnu/packages/node.scm
> +++ b/gnu/packages/node.scm
> @@ -250,7 +250,21 @@ (define-public node
>                  (find-files (string-append prefix "/lib/node_modules")
>                              (lambda (file stat)
>                                (executable-file? file))
> -                            #:stat lstat))))))))
> +                            #:stat lstat)))))
> +         (add-after 'install 'install-npmrc
> +           (lambda* (#:key outputs #:allow-other-keys)
> +             (let* ((out (assoc-ref outputs "out")))
> +               (with-output-to-file
> +                   ;; Use the config file "primarily for distribution
> +                   ;; maintainers" rather than "{prefix}/etc/npmrc",
> +                   ;; especially because node-build-system uses --prefix
> +                   ;; to install things to their store paths:
> +                   (string-append out "/lib/node_modules/npm/npmrc")
> +                 (lambda ()
> +                   ;; Tell npm (mostly node-gyp) where to find our
> +                   ;; installed headers so it doesn't try to
> +                   ;; download them from the internet:
> +                   (format #t "nodedir=~a\n" out)))))))))

When I run `node-gyp configure' in my tree-sitter packages, it's not
able to find the node dir and tries to download headers. So I need to
set `npm_config_nodedir' manually, like so:

--8<---------------cut here---------------start------------->8---
(add-after 'configure 'configure-gyp
  (lambda* (#:key inputs #:allow-other-keys)
    (let ((node (assoc-ref inputs "node")))
      (setenv "npm_config_nodedir" node)
      (invoke
        (string-append
          node
          "/lib/node_modules/npm/bin/node-gyp-bin/node-gyp")
        "configure"))))
--8<---------------cut here---------------end--------------->8---

I'm wondering if the npmrc approach here is working properly? I see in
another patch you've used the `npx' command to run `node-gyp rebuild',
should I be using that?

Thanks,
Pierre
[signature.asc (application/pgp-signature, inline)]

This bug report was last modified 3 years and 195 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.