Skip to content

Latest commit

 

History

History
202 lines (168 loc) · 6.18 KB

File metadata and controls

202 lines (168 loc) · 6.18 KB
titletext description
How to use specific Node.js versions, and private packages
Your project may require a specific version of Node.js. Or, you may need to use private npm packages. This section shows you how to do both.

Node.js

Node.js, or just Node, is a popular JavaScript runtime that can be used for application development or system tools.

This section covers the following topics:

Specify the Node version

Node itself is evolving rapidly, which means that new features are available regularly. It also means that existing features might change or become deprecated. Your use of Node may depend on specific versions in order to function correctly. See how to use a specific version of Node in the following steps:

  1. Log in to the buddybuild dashboard.

  2. The Current App button Choose the app that requires a specific Node version by moving your pointer over the current app button in the top toolbar. The Apps dropdown appears:

    The Apps dropdown

  3. Select the app that needs a specific Node version by clicking it in the dropdown. The Builds page for your app appears:

    The Builds screen

    The App dropdown’s filter field If you have many apps, you can type the app’s name (or portion thereof) into the search field; only apps with matching names are displayed.

    The sort order button Or, you can click the sort order button to display a select menu of sorting approaches. Click the select menu to display all of the approaches:

    • Alphabetical (A-Z) Select to show apps in normal, alphabetical order. This is the default.

    • Alphabetical (Z-A) Select to show apps in reverse alphabetical order.

    • Created Date Select to show the most recently added apps first.

  4. The App Settings button Click the App Settings button in the top toolbar. The App Settings screen is displayed:

    The App Settings screen

  5. The Environment tab Click the Environment tab. The Environment settings are displayed:

    The Environment settings

  6. The Node versions select menu Click the Node version select menu to display the available Node versions.

  7. Click the version of Node that you need for your build.

That’s it! From now on, builds of your app use the selected Node version.

Private npm packages

You can configure buddybuild to use private npm packages. This makes it much easier to mix public packages with custom, private code you have written. For more information on private packages, see Working with private modules.

Using private npm packages requires an account on npmjs.com. If you do not already have an account, sign up for a free account.

Once you have an npmjs.com account, you can then acquire the access_token which gives you access to all npm packages to which you have at least read permissions. Then you can set a buddybuild environment variable to make the access token available to your build. Finally, you can create (or update) the buddybuild_postclone.sh script to configure npm to use your access token and install your private package dependencies.

Follow these steps:

  1. Capture the npm access token:

    1. From the command line, log in to npm:

      npm login

      You are prompted for your npmjs.com username, password, and email address.

    2. Copy the access token from ~/.npmrc.

      cat ~/.npmrc
      //registry.npmjs.org/:_authToken=cb31c41d-3bq8-7285-fe20-361ea25e3c1e

      The access token is the value after _authToken=, in this case: cb31c41d-3bq8-7285-fe20-361ea25e3c1e.

  2. Set a buddybuild environment variable, to provide the npm access token to your build:

    1. Log in to the buddybuild dashboard.

    2. The App Settings button Click App Settings button in the top toolbar. The Default build configuration screen is displayed:

      The Default build configuration screen

    3. The Environment tab Click the Environment tab. The Environment settings screen is displayed:

      The Environment settings

    4. The Configure button In the Environment variables row, click the Configure button. The Environment variables screen is displayed:

      The Environment variables screen

    5. In the Name field, enter NPM_AUTH_TOKEN.

    6. In the Value field, enter the npm access token that you copied previously.

    7. The Create button Click the Create button.

  3. Configure the build to use the environment variable:

    1. Create (or update) the buddybuild_postclone.sh script in the root of your app’s repository, so that it contains the following lines:

      #!/usr/bin/env bash
      
      npm config set //registry.npmjs.org/:_authToken $NPM_AUTH_TOKEN
      npm install
    2. Commit the change to buddybuild_postclone.sh.

That’s it! Your builds now have access to your npm access token, and your app’s npm dependencies are installed, including any private packages where you have read permissions.