Difference between revisions of "Node.js package guidelines"

From ArchWiki
Jump to navigation Jump to search
(Add pt interlanguage link)
(remove cd)
(2 intermediate revisions by the same user not shown)
Line 20: Line 20:
 
{{bc|<nowiki>
 
{{bc|<nowiki>
 
package() {
 
package() {
    cd $srcdir/$pkgname-$pkgver
+
     npm install -g --user root --prefix "$pkgdir"/usr "$srcdir"/source-tarball.tar.gz
     npm install -g --user root --prefix "$pkgdir"/usr
+
 
 
     # Non-deterministic race in npm gives 777 permissions to random directories.
 
     # Non-deterministic race in npm gives 777 permissions to random directories.
 
     # See https://github.com/npm/npm/issues/9359 for details.
 
     # See https://github.com/npm/npm/issues/9359 for details.

Revision as of 14:17, 13 July 2018

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:

makedepends=('npm')

This is a minimal package function:

package() {
    npm install -g --user root --prefix "$pkgdir"/usr "$srcdir"/source-tarball.tar.gz

    # Non-deterministic race in npm gives 777 permissions to random directories.
    # See https://github.com/npm/npm/issues/9359 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