install-sharp.md 719 字节
Newer Older
S
Steven 已提交
1 2 3 4
# Install `sharp` to Use Built-In Image Optimization

#### Why This Error Occurred

5 6 7
Using Next.js' built-in Image Optimization requires that you install `sharp`.

Since `sharp` is optional, it may have been skipped if you installed `next` with the [`--no-optional`](https://docs.npmjs.com/cli/install) flag or it may have been skipped if your platform does not support `sharp`.
S
Steven 已提交
8 9 10

#### Possible Ways to Fix It

11
Option 1: Install the `sharp` package in your project.
S
Steven 已提交
12 13 14 15 16 17

```bash
npm i sharp
# or
yarn add sharp
```
18 19 20 21 22 23 24 25 26 27 28

Option 2: Configure an external loader in `next.config.js` such as [imgix](https://imgix.com).

```js
module.exports = {
  images: {
    path: 'https://example.com/myaccount/',
    loader: 'imgix',
  },
}
```