An import works in Code, but does not work in `yarn start`

In MS Code this import is not highlighted as an error:

import { keccak256 } from "ethers/lib/utils";

but when I try to yarn start, it produces errors.

[1] ✘ [ERROR] Could not resolve "ethers/lib/utils"
[1] 
[1]     ../util/eth.ts:1:26:
[1]       1 │ import { keccak256 } from "ethers/lib/utils";
[1]         ╵                           ~~~~~~~~~~~~~~~~~~
[1] 
[1]   The path "./lib/utils" is not exported by package "ethers":
[1] 
[1]     ../node_modules/ethers/package.json:67:13:
[1]       67 │   "exports": {
[1]          ╵              ^
[1] 
[1]   You can mark the path "ethers/lib/utils" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.

I don’t understand what imports in package.json mean and how to use it together with Code, in such a way that both code and yarn start would be satisfied.