Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Olaf Mandel <o.mandel@menlosystems.com>
To: openembedded-core@lists.openembedded.org
Cc: marex@denx.de, Olaf Mandel <o.mandel@menlosystems.com>
Subject: [PATCH] npm: change install directory to upstream default
Date: Fri, 19 Oct 2018 15:22:14 +0000	[thread overview]
Message-ID: <20181019152214.1600-1-o.mandel@menlosystems.com> (raw)

The node binary searches for packages in a number of locations, the last
of which is $PREFIX/lib/node (here: /usr/lib/node) from the list of
GLOBAL_FOLDERS [1]. Change the installation directory for all packages
depending on npm.bbclass to that location. This removes the need to
define the NODE_PATH variable to the non-standard /usr/lib/node_modules
value.

While the Tips for Package Managers [2] discusses installing packages to
/usr/lib/node_modules/<name>/<version>, this has several drawbacks:

 * it does not work for the REPL as mentioned in the documentation
 * it also does not work for any code _not_ installed as a global
   package under /usr/lib/node_modules (e.g. /usr/share/foo.js will not
   find any packages below /usr/lib)
 * using the non-default location and then having to set NODE_PATH
   barely saves any time: there are only two file-system lookups (to the
   legacy $HOME/.node_modules and $HOME/.node_libraries) directories
   before the library would be found

And the suggestion was made in the context of deduping the node_modules
tree by installing all packages in a flat hierarchy and using symlinks
to the correct version of each dependency. This is not what OpenEmbedded
does, so none of those benefits (deduping, cleaner packages) are being
had by shifting the installation directory to /usr/lib/node_modules.

[1]: https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
[2]: https://nodejs.org/api/modules.html#modules_addenda_package_manager_tips

Signed-off-by: Olaf Mandel <o.mandel@menlosystems.com>
---
 meta/classes/npm.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/classes/npm.bbclass b/meta/classes/npm.bbclass
index c351ff0866..d5ff0c6d57 100644
--- a/meta/classes/npm.bbclass
+++ b/meta/classes/npm.bbclass
@@ -10,7 +10,7 @@ def node_pkgname(d):
 
 NPMPN ?= "${@node_pkgname(d)}"
 
-NPM_INSTALLDIR = "${D}${libdir}/node_modules/${NPMPN}"
+NPM_INSTALLDIR = "${D}${libdir}/node/${NPMPN}"
 
 # function maps arch names to npm arch names
 def npm_oe_arch_map(target_arch, d):
-- 
2.11.0



             reply	other threads:[~2018-10-19 15:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-19 15:22 Olaf Mandel [this message]
2018-10-19 16:53 ` [PATCH] npm: change install directory to upstream default Marek Vasut
2018-10-22  9:50   ` [PATCH v2] " Olaf Mandel
2018-10-22 10:10     ` [PATCH v3] " Olaf Mandel
2018-10-22 10:03 ` ✗ patchtest: failure for npm: change install directory to upstream default (rev2) Patchwork
2018-10-22 10:33 ` ✗ patchtest: failure for npm: change install directory to upstream default (rev3) Patchwork
2018-10-22 10:45   ` Olaf Mandel
2018-10-22 22:45     ` Richard Purdie
2018-10-23 10:30       ` Olaf Mandel
2018-10-26 17:46 ` [PATCH] npm: change install directory to upstream default Dan McGregor
2018-10-29 10:39   ` Olaf Mandel
2018-10-31 16:38     ` Dan McGregor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181019152214.1600-1-o.mandel@menlosystems.com \
    --to=o.mandel@menlosystems.com \
    --cc=marex@denx.de \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox