1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-09 17:39:31 +00:00

npm.bbclass: Fix building node modules with npm@5

npm cache clear throws an error with npm@5 and suggests to
use npm cache verify instead. But our cache is actually empty,
so use npm cache clear --force.

npm install in the source directory creates symlinks with npm@5.

Use a combination of npm pack and npm install module-version.tgz
that works the same way with older and new npm versions and is
guaranteed to create actual copies instead of directory symlinks.

This change allows using nodejs 8.x LTS, tested with 8.9.4.

(From OE-Core rev: 2d7d2a460842c8747df17990970f22f4a11f36f6)

Signed-off-by: Zoltán Böszörményi <zboszor@pr.hu>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Böszörményi Zoltán
2018-02-01 14:08:30 +01:00
committed by Richard Purdie
parent bb40162b2b
commit d38e1e2c2e
+3 -2
View File
@@ -31,7 +31,7 @@ npm_do_compile() {
fi fi
npm set cache ${WORKDIR}/npm_cache npm set cache ${WORKDIR}/npm_cache
# clear cache before every build # clear cache before every build
npm cache clear npm cache clear --force
# Install pkg into ${S} without going to the registry # Install pkg into ${S} without going to the registry
if [ "${NPM_INSTALL_DEV}" = "1" ]; then if [ "${NPM_INSTALL_DEV}" = "1" ]; then
npm --arch=${NPM_ARCH} --target_arch=${NPM_ARCH} --no-registry install npm --arch=${NPM_ARCH} --target_arch=${NPM_ARCH} --no-registry install
@@ -45,7 +45,8 @@ npm_do_install() {
# be created in this directory # be created in this directory
export HOME=${WORKDIR} export HOME=${WORKDIR}
mkdir -p ${NPM_INSTALLDIR}/ mkdir -p ${NPM_INSTALLDIR}/
npm install --prefix ${D}${prefix} -g --arch=${NPM_ARCH} --target_arch=${NPM_ARCH} --production --no-registry npm pack .
npm install --prefix ${D}${prefix} -g --arch=${NPM_ARCH} --target_arch=${NPM_ARCH} --production --no-registry ${PN}-${PV}.tgz
if [ -d ${D}${prefix}/etc ] ; then if [ -d ${D}${prefix}/etc ] ; then
# This will be empty # This will be empty
rmdir ${D}${prefix}/etc rmdir ${D}${prefix}/etc