背景 Cykinso の 研究&データ技術開発 の山﨑です。 Nest.js で本番環境のために npm run build し、正常に build できているか試すために npm run start:prod を実行したところ、以下のエラーが出てしまいました。 > npm run start:prod > backend@0.0.1 start:prod > node dist/main node:internal/modules/cjs/loader:1147 throw err; ^ Error: Cannot find module '/workspace/xxxxx/dist/main' at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15) at Module._load (node:inter
![Nest.js で start:prod 実行時に Error: Cannot find module 'dist/main' と表示される](https://cdn-ak-scissors.b.st-hatena.com/image/square/fd8be3e77558ec73a5c2fd439099d70763c695e0/height=288;version=1;width=512/https%3A%2F%2Fres.cloudinary.com%2Fzenn%2Fimage%2Fupload%2Fs--vOah1H83--%2Fc_fit%252Cg_north_west%252Cl_text%3Anotosansjp-medium.otf_55%3ANest.js%252520%2525E3%252581%2525A7%252520start%25253Aprod%252520%2525E5%2525AE%25259F%2525E8%2525A1%25258C%2525E6%252599%252582%2525E3%252581%2525AB%252520Error%25253A%252520Cannot%252520find%252520module%252520%252527dist...%252Cw_1010%252Cx_90%252Cy_100%2Fg_south_west%252Cl_text%3Anotosansjp-medium.otf_34%3AyamasaKit%252Cx_220%252Cy_108%2Fbo_3px_solid_rgb%3Ad6e3ed%252Cg_south_west%252Ch_90%252Cl_fetch%3AaHR0cHM6Ly9zdG9yYWdlLmdvb2dsZWFwaXMuY29tL3plbm4tdXNlci11cGxvYWQvYXZhdGFyLzFmNTQzYzVhYjguanBlZw%3D%3D%252Cr_20%252Cw_90%252Cx_92%252Cy_102%2Fco_rgb%3A6e7b85%252Cg_south_west%252Cl_text%3Anotosansjp-medium.otf_30%3ACykinso%252527s%252520Tech%252520Blog%252Cx_220%252Cy_160%2Fbo_4px_solid_white%252Cg_south_west%252Ch_50%252Cl_fetch%3AaHR0cHM6Ly9zdG9yYWdlLmdvb2dsZWFwaXMuY29tL3plbm4tdXNlci11cGxvYWQvYXZhdGFyLzg1ZDc4NDNmZDguanBlZw%3D%3D%252Cr_max%252Cw_50%252Cx_139%252Cy_84%2Fv1627283836%2Fdefault%2Fog-base-w1200-v2.png)