npm init
itself doesn’t have a flag to auto-set "type": "module"
in package.json
. By default, it creates CommonJS projects.
So, there’s no direct npm init
flag for "type": "module"
. The simplest automated way is:
npm init -y && npm pkg set type=module