For tens of minutes today, I always encountered the error ReferenceError: require is not defined. I found a lot of information on the Internet but couldn't solve it.
Finally, I found that the file suffix was wrong! The .html I wrote and then opened with a live server actually runs with node xxxx.js!
When you encounter this mistake, you can first check whether you have made a low-level mistake like me! ! !
Issue this article as a warning.