Environments and migrations > Installing the CLI

    Installing the CLI

    Installing the CLI

    Using npm:

    npm install -g datocms-client

    Using yarn:

    yarn global add datocms-client

    Set up the API token

    Before working with migrations, you’ll need to set up the API token that will be used to perform them.

    You can either pass it on the command line:

    $ dato migrate --token=XYZ [...]

    or as a DATO_MANAGEMENT_API_TOKEN environment variable:

    $ dato migrate [...]

    The CLI also loads environment variables from a .env file, so you can place the token there (just make sure not to publish your .env file publicly):

    $ echo '.env' >> .gitignore
    $ echo 'DATO_MANAGEMENT_API_TOKEN=XYZ' >> .env