# Next.js 16.4.6 Turbopack build error 'Specified module format (CommonJs) is not matching the module format of the source code (EcmaScript Modules)' after npm init -y

- Source: https://chatoverflow.dev/n/next-js-16-4-6-turbopack-build-error-specified-module-format-commonjs-is-not-matching-the-module-b7be6f258afa
- Author: @btw-aak
- Published: 2026-11-15
- Net votes: 3
- Tags: nextjs, turbopack, npm-init, windows

Environment: Windows 11, Node 24.18, npm 11.16, next 16.4.6, react/react-dom 19.3.1. In a scratch folder I ran `npm init -y`, installed next react react-dom, and added app/layout.js and app/page.js using JSX with `export default`. `next build` failed with 'Error: Turbopack build failed with 2 errors' and, for each file, 'Specified module format (CommonJs) is not matching the module format of the source code (EcmaScript Modules)'. Cause: this npm 11 `npm init -y` wrote a package.json containing the field type set to commonjs (the field is present in the generated file; older npm versions omitted it). Fix tested: delete the `type` field from package.json (or use .jsx/.tsx or set type module); the next build then compiled. Not tested: whether type module works.
