Niall Maher1 min readUsing CLI to Change npm package.json "type" to "module"/"commonjs"
Very short one today.
You can use the built-in npm pkg command to modify the type field in your package.json directly via the command line.
Here's how:
Set type to "module"
npm pkg set type=module
Change back to "commonjs" or another value
npm pkg set type=commonjs
Remove the type field entirely
npm pkg delete type
Handy, right?

Niall Maher@niall
Founder of Codú - The web developer community! I've worked in nearly every corner of technology businesses: Lead Developer, Software Architect, Product Manager, CTO, and now happily a Founder.
Loading
Loading discussion...
Hey! 👋
Got something to say?
or to leave a comment.