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.
Local installation (recommended)
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 --save-dev
This should add prisma
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 (1.19.2+)
Install with Yarn:
yarn add prisma --dev
This should add prisma
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
We recommend that you keep both the prisma
and @prisma/client
packages in sync to avoid any unexpected errors or behaviors.
Global installation (not recommended)
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
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
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
orhttp_proxy
: Proxy URL for http traffic, for examplehttp://localhost:8080
HTTPS_PROXY
orhttps_proxy
: Proxy URL for https traffic, for examplehttps://localhost:8080
To get a local proxy, you can also use the
proxy
module.