This message was deleted.
# ask-questions
w
This message was deleted.
s
Hi @microscopic-refrigerator-66345 For vanilla Node.js, you should use the CommonJS style of importing instead (e.g.
const GrowthBook = require('@growthbook/growthbook').GrowthBook
). (Our Node.js section in the docs hints at this.) We don't support ESM imports currently. If I may ask, do you know what sort of project you intend to use GrowthBook for? Typically our SDK is used with a web server such as Express. You might have a better time trying out GrowthBook by setting up a web server in Node.js first, and then installing GrowthBook onto it.
Copy code
const GrowthBook = require("@growthbook/growthbook").GrowthBook;

// Create a GrowthBook instance
const gb = new GrowthBook({
  apiHost: "<https://cdn.growthbook.io>",
  clientKey: "sdk-key",
  // Enable easier debugging of feature flags during development
  enableDevMode: true,
});

// Wait for features to be available
gb.loadFeatures({ autoRefresh: true }).then(() => {
  const color = gb.getFeatureValue("button-color");
  console.log("color", color);
});
m
Thank you, it worked! I’m planning to use GrowthBook in a particular project for change the behavior for my node application;
182 Views