A newer version of this documentation is available.

View Latest

Couchbase Node.js SDK Installation

      +
      Installation instructions for the Couchbase Node.js Client.

      The Couchbase Node.js Client will run on any supported LTS version of Node.js — currently, 12.x, 14.x, and 16.x.

      Installing the SDK

      The Couchbase Node.js Client will run on any supported LTS version of Node.js.

      $ npm install couchbase --save

      Note: This will download the latest Couchbase Node.js SDK, and add a dependency to your package.json.

      Information on new features, fixes, known issues, as well as information on how to install older release versions is in the release notes.

      TypeScript Support

      Follow this section only if you intend to use TypeScript instead of JavaScript.

      Since release 3.2, the Node.js SDK has added full support for the TypeScript programming language.

      $ npm install -g typescript ts-node

      This will install TypeScript globally on your machine and allow you to run commands with the tsc cli. You will have noticed that we also install ts-node which is a handy execution utility that will help us run the example later on.

      Run tsc --init in your project directory to generate a tsconfig.json file. This will set you up with some initial configurations, which should suffice for our purposes.

      Should you wish to make changes in future you can simply edit the file:

      {
        "compilerOptions": {
         "disableReferencedProjectLoad": true,             
          "target": "es5",                                   
          "module": "commonjs",                                
          "esModuleInterop": true,                             
          "forceConsistentCasingInFileNames": true,            
          "strict": true,                                     
          "skipLibCheck": true                                 
        }
      }

      Note that the example above does not include the generated comments for readability.