No results for ""
EXPAND ALL
  • Home
  • API docs

GIVE DOCS FEEDBACK

Node.js (server-side) SDK 5.x to 6.0 migration guide

Read time: 3 minutes
Last edited: Jan 18, 2024

Overview

This topic explains how to adapt code that currently uses a 5.x version of the Node.js server-side SDK to use version 6.0 or later.

Before you migrate to 6.0, update to the latest 5.x version. To learn more about updating to the latest 5.x version, visit the SDK's GitHub repository.

Identifying Node.js versions for the 6.0 SDK

The 6.0 version of the SDK is compatible with Node.js versions 12 and higher. LaunchDarkly no longer supports older Node.js versions, as is documented in the End of Life policy.

LaunchDarkly also no longer supports some Node.js versions above 12 that are not long-term-support versions and have reached their end of life. To learn more, read the Node.js releases page.

Understanding changes to dependencies

To reduce the size of the SDK code, some dependencies have been removed or made optional.

  • redis: The Redis integration is no longer included in the SDK package. It is now a separate package. To learn more, read Understanding changes to the Redis integration.
  • winston: The SDK no longer uses the winston package by default. You can still use winston. To learn more, read Understanding changes to logging.
  • yaml: The SDK no longer uses the yaml package by default. This only affects FileDataSource. To learn more, read Understanding changes to the file data source.

Understanding changes to the Redis integration

If you use the Redis integration, it has a different location for the 6.0 version of the SDK.

Instead of being bundled in the main SDK package, it is now in its own package: launchdarkly-node-server-sdk-redis.

Add this dependency to your project by editing package.json, or with this command:

npm install launchdarkly-node-server-sdk-redis

Then, in any JavaScript files where you were previously referring to RedisFeatureStore, change the reference as shown here:

const LaunchDarkly = require('launchdarkly-node-server-sdk');
const store = LaunchDarkly.RedisFeatureStore();

Understanding changes to logging

Previously, if you did not specify your own logger in the logger property, the SDK used winston to create a logger.

In versions 6.0 and higher of the SDK, if you do not specify your own logger, the SDK writes log output directly to the console. It uses the same format that it was previously using with winston, so you may not notice any difference.

If you want to use winston, you can still create a winston logger and put it in the SDK's logger property. This works exactly the same as before. The only difference is that you must make sure winston exists as a dependency in your project, instead of the dependency being provided automatically by the SDK.

The SDK also has a new option to allow configuring a simple logger without using winston. To learn more, read basicLogger.

Understanding changes to the file data source

The FileDataSource component allows you to load feature flag data from files. The file data can be either JSON or YAML.

In versions 6.0 and higher of the SDK, the yaml package is no longer loaded by default. Without it, FileDataSource will only allow JSON files.

If you want to use YAML data files, add the yaml package as a dependency in your project. The SDK automatically detects that yaml is present, and enables YAML parsing in FileDataSource.

Understanding what was deprecated

All types and methods that were marked as deprecated/obsolete in the last 5.x release have been removed from the 6.0 release. If you were using these with a recent version previously, you should already have received deprecation warnings at build time or runtime, with suggestions about their recommended replacements.