Node.js package guidelines

From ArchWiki
Revision as of 16:34, 8 March 2018 by Eschwartz (talk | contribs) (Using npm: fix wiki formatting in code snippet)
Jump to: navigation, search
Package creation guidelines

CLRCrossEclipseElectronFree PascalGNOMEGoHaskellJavaKDEKernelLispMinGWNode.jsNonfreeOCamlPerlPHPPythonRRubyRustVCSWebWine

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:


This is a minimal package function:

package() {
    cd $srcdir/$pkgname-$pkgver
    npm install -g --user root --prefix "$pkgdir"/usr
    # Non-deterministic race in npm gives 777 permissions to random directories.
    # See for details.
    find "${pkgdir}"/usr -type d -exec chmod 755 {} +

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