Node.js package guidelines

From ArchWiki
Jump to: navigation, search
Package creation guidelines

CLRCrossEclipseFree PascalGNOMEGoHaskellJavaKDEKernelLispMinGWNode.jsNonfreeOCamlPerlPHPPythonRubyVCSWebWine

This document covers standards and guidelines on writing PKGBUILDs for Node.js packages.

Package naming

Package names should start with a nodejs- prefix.

Using npm

When installing with npm, add it as a build dependency:

makedepends=('npm')

This is a minimal package function:

package() {
    cd $srcdir/$pkgname-$pkgver
    npm install -g --user root --prefix "$pkgdir"/usr
}

Setting temporary cache

When npm processes package.json in order to build a package it downloads dependencies to its default cache folder at $HOME/.npm. To avoid littering user's home folder we can temporarily set a different cache folder with --cache flag:

Download dependencies to ${srcdir}/npm-cache and install them in package directory

npm install --cache "${srcdir}/npm-cache" 

Continue with packaging as usual

npm run packager