1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【vercel】Next.jsのデプロイがうまくいかなかった時の話(Error: Cannot find module '/vercel/path0/node_modules/.pnpm/bcrypt)

Posted at

エラー内容

Next.jsの公式チュートリアルの第6章のデプロイ時にエラーが起きました

[Error: Cannot find module '/vercel/path0/node_modules/.pnpm/bcrypt@5.1.1/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node'
> Build error occurred
[Error: Failed to collect page data for /seed] { type: 'Error' }
 ELIFECYCLE  Command failed with exit code 1.
Error: Command "pnpm run build" exited with 1

原因

bcryptと現在の環境の互換性がなかったため

修正内容

app/seed/route.tsの修正

app/seed/route.ts
- import bcrypt from 'bcrypt';
+ import bcrypt from 'bcryptjs';

package.jsonの修正

package.json
- "bcrypt": "^5.1.1",
+ "bcryptjs": "^3.0.2",

pnpm-lock.yamlの更新

pnpm i --lockfile-only

まとめ

bcryptと現在の環境の互換性がなかったため、bcryptjsに変更しました。package.jsonの依存関係を更新し、pnpm-lock.yamlを再生成することで問題を解決しました。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?