I am deploying a CF page function with an external dependecy
I installed it locally with npm install jspdf and then my pages works locally. It also generated package.json and package-lock.json. I commited and pushed to my repo, but then my build fails with the following logs:
3:08:10.954 Cloning repository...
23:08:12.065 From https://github.com/charelF/wg-form-page
23:08:12.065 * branch bf14b72070afb75b1b8c4a5e13d5caa3b7aea792 -> FETCH_HEAD
23:08:12.066
23:08:12.110 HEAD is now at bf14b72 nice
23:08:12.111
23:08:12.219
23:08:12.252 Success: Finished cloning repository files
23:08:12.979 No build command specified. Skipping build step.
23:08:12.980 Found Functions directory at /functions. Uploading.
23:08:14.565 ✘ [ERROR] 1 error(s) and 0 warning(s) when compiling Worker.
23:08:14.566
23:08:14.566
23:08:14.569
23:08:14.570 ✘ [ERROR] Could not resolve "jspdf"
23:08:14.571
23:08:14.571 pdfmaker.js:1:22:
23:08:14.571 1 │ import { jsPDF } from 'jspdf'
23:08:14.571 ╵ ~~~~~~~
23:08:14.571
23:08:14.571 You can mark the path "jspdf" as external to exclude it from the bundle, which will remove this error.
23:08:14.572
23:08:14.572
23:08:14.575 ✘ [ERROR] Build failed with 1 error:
23:08:14.575
23:08:14.575 pdfmaker.js:1:22: ERROR: Could not resolve "jspdf"
23:08:14.575
23:08:14.575
23:08:14.585 Failed building Pages Functions.
23:08:15.476 Failed: an internal error occurred. If this continues, contact support: https://cfl.re/3WgEyrH
Since i used no framework, I left the build command empty. However then nothing gets build, which is why the above logs show the error. The solution is to include anything in the build command. In my case, I put:
echo "Hello World!"in the buidl command and then the deployment worked.Originally asked on discord: https://discord.com/channels/595317990191398933/910978223968518144/1155069343365865534
A github issue was opened because of this issue: https://github.com/cloudflare/cloudflare-docs/issues/10841