An opinionated tool to install node.js, npm, npx and yarn in build scripts.
nnny is an opinionated tool that provides an extremely simple way to install
node.js, npm, npx, and yarn within your build scripts.
Just cd into your Node app's directory, and run:
$ curl -so- https://raw.githubusercontent.com/MeLlamoPablo/nnny/v1.0.0/nnny.sh | sudo bashIn order to keep nnny ultra simple, it must follow some opinions, which will
make it useless for some use cases. Those opinions are:
-
nnnyis only intended to be used in build scripts (Dockerfiles to build Docker images, Vagrantfiles to build Vagrant VMs, or just good ol' shell scripts to build AWS AMIs).nnny's installs are immutable, which means that it doesn't provide updates. Instead, to update, you need to rebuild the whole image. This rendersnnnyuseless for day to day use, for which you should use other tools like nvm. -
nnnywill extract yournode,npmandyarnversions from your engines field inpackage.json(npx's version depends onnpm's). There's no other way to specify the desired versions.As you would have guessed,
nnnyis meant to do a deterministic per-project install. If you have multiple projects (e.g: one Express app for the backend and one React app for the frontend), consider having separate containers/images/VMs of each.For instance, one good use case would be to have a Docker container to perform the production build of the React app, which then will send the built images to a second Docker container that will host the backend (which serves the frontend).
-
nnnydoesn't support SemVer. You must always provide the exact version numbers that you need.The NPM ecosystem is highly controversial because of poor (in my opinion, and in many others') management of the dependency structure. There are many cases (left-pad, request, npm v5.7.0...) that demonstrate that the whole ecosystem is a mess.
nnny's purpose is to provide deterministic builds. In order to achieve so, it must always install the exact same version. This obviously comes with the drawback that you must watch out for security bugs and update your versions in the case of such an event. -
nnnyis only tested onUbuntu 18.04, although it should run just fine on other Linux systems.nnnywill probably not work on OSX, and it absolutely will not work on Windows. -
nnnywill placenode,npm,npxandyarnin/usr/bin/. There is no way to specify the destination path.
In order to test nnny, just execute the test.sh file (preferably inside a
container and not in your main system).
This repository contains a Dockerfile to make running the tests easy:
$ git clone https://github.com/MeLlamoPablo/nnny.git
$ cd nnny
$ docker build -t nnny .
$ docker run -i nnny /nnny/test.sh