Thanks, Stephen.
The error happens in the function block async function handlePaymentMethodSubmission(event, paymentMethod) of the square.js sample file.
I had not tried to test production mode on localhost (my iMac). I did just now and I got a 400 Bad Request response. It was on the following line of code:
/square.cjs.development.js:16687:15
Before, I was actually porting the sample code to my website when I got stuck.
I am still wondering about the access token. I saw somewhere else in the documentation a warning NOT to upload the .env file.