Hugo asset pipeline security.exec.allow error

If you hit this error with recent versions of Hugo:

Error: Error building site: BABEL: failed to transform "js/main.js" (application/javascript): access denied: "babel" is not whitelisted in policy "security.exec.allow"; the current security configuration is:

You need to allow babel in Hugo’s security rules in the config file, like this:

[security]
	[security.exec]
		allow = ['^go$', '^npx$', '^postcss$', '^babel$']

Tech mentioned