]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commit
npm: change install directory to upstream default
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 22 Oct 2018 22:43:32 +0000 (23:43 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 25 Oct 2018 13:53:44 +0000 (14:53 +0100)
commite9270af4296ce2af292059617a717e42fc17425c
tree21efdf44ac3fec4ff49bc3f84e63312e300d4579
parent1c03ada82de69a7f04ebb191fa560c02a2d29ea7
npm: change install directory to upstream default

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]. So 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.

The choice of a "proper" installation path is not helped by npm
installing to /usr/lib/node_modules if asked to install globally. Still,
using the location expected by nodejs (/usr/lib/node) seems the right
choice.

[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

(From OE-Core rev: c73bc49038effd64f2c2542c1f4da8b6a4168477)

Signed-off-by: Olaf Mandel <o.mandel@menlosystems.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/npm.bbclass