srphillips / asdf-nodejs

Node.js plugin for asdf version manager
https://github.com/asdf-vm/asdf
MIT License
0 stars 0 forks source link

This repo was forked from the official asdf-nodejs plugin repository to attempt to fix a few basic issues when trying to switch from nvm:

asdf-nodejs

Build Status

Node.js plugin for asdf version manager

The plugin properly validates OpenPGP signatures to check the authenticity of the package. Requires gpg to be available during package installs

Requirements

MacOS

Linux (Debian)

Install

Install the plugin:

asdf plugin-add nodejs https://github.com/asdf-vm/asdf-nodejs.git

Import the Node.js release team's OpenPGP keys to main keyring:

bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring

If you installed asdf with brew adjust the path to the Node.js plugin:

bash /usr/local/opt/asdf/plugins/nodejs/bin/import-release-team-keyring

Use

Check asdf readme for instructions on how to install & manage versions of Node.js.

When installing Node.js using asdf install, you can pass custom configure options with the following env vars:

.nvmrc and .node-version files

asdf uses the .tool-versions for auto-switching between software versions. To ease migration, you can have it read an existing .nvmrc or .node-version file to find out what version of Node.js should be used. To do this, add the following to $HOME/.asdfrc:

legacy_version_file = yes

Default npm Packages

asdf-nodejs can automatically install a set of default set of npm package right after installing a Node.js version. To enable this feature, provide a $HOME/.default-npm-packages file that lists one package per line, for example:

lodash
request
express

Using a dedicated OpenPGP keyring

The gpg commands above imports the OpenPGP public keys in your main OpenPGP keyring. However, you can also use a dedicated keyring in order to mitigate this issue.

To use a dedicated keyring, prepare the dedicated keyring and set it as the default keyring in the current shell:

export GNUPGHOME="${ASDF_DIR:-$HOME/.asdf}/keyrings/nodejs" && mkdir -p "$GNUPGHOME" && chmod 0700 "$GNUPGHOME"

# Imports Node.js release team's OpenPGP keys to the keyring
bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring

Again, if you used brew to manage the asdf installtion use the following bash commands:

export GNUPGHOME="bash /usr/local/opt/asdf/keyrings/nodejs" && mkdir -p "$GNUPGHOME" && chmod 0700 "$GNUPGHOME"

# Imports Node.js release team's OpenPGP keys to the keyring
bash /usr/local/opt/asdf/plugins/nodejs/bin/import-release-team-keyring

Related notes

This behavior can be influenced by the NODEJS_CHECK_SIGNATURES env var which supports the following options: