Installing the Prisma CLI

The Prisma CLI is available as an npm package. We recommend that you install the Prisma CLI locally in your project's package.json to avoid version conflicts.

See Prisma CLI command reference for a complete list of commands.

The Prisma CLI is typically installed as a development dependency, that's why the --save-dev (npm) and --dev (Yarn) options are used in the commands below.

npm

Install with npm:

npm install @prisma/cli --save-dev

This should add @prisma/cli to the devDependencies in your package.json. You can then invoke the locally installed CLI with the prisma command prefixed with npx:

npx prisma

Here's an example for invoking the generate command:

npx prisma generate

Yarn

Install with Yarn:

yarn add @prisma/cli --dev

This should add @prisma/cli to the devDependencies in your package.json. You can then invoke the locally installed CLI with the prisma command prefixed with yarn:

yarn prisma

Here's an example for invoking the generate command:

yarn prisma generate

While it is recommended to locally install the Prisma CLI, you can also install it globally on your machine.

Warning: If you have several Prisma projects on your machine, a global installation can lead to version conflicts between these projects.

npm

Install with npm:

npm install -g @prisma/cli

You can then invoke the globally installed CLI with the prisma command like so:

prisma

Here's an example for invoking the generate command:

prisma generate

Yarn

Install with Yarn:

yarn global add @prisma/cli

You can then invoke the globally installed CLI with the prisma command like so:

prisma

Here's an example for invoking the generate command:

prisma generate

Using a HTTP proxy for the CLI

Prisma CLI supports custom HTTP proxies. This is particularly relevant when being behind a corporate firewall.

To activate the proxy, provide the environment variables HTTP_PROXY and/or HTTPS_PROXY. The behavior is very similar to how the npm CLI handles this.

The following environment variables can be provided:

  • HTTP_PROXY or http_proxy: Proxy URL for http traffic, for example http://localhost:8080
  • HTTPS_PROXY or https_proxy: Proxy URL for https traffic, for example https://localhost:8080

To get a local proxy, you can also use the proxy module.

Edit this page on GitHub