NextJS Deployment fails unless devDependencies moved to dependencies in package.json

I am deployed a fresh installation of nextjs using typescript

npx create-next-app@latest foo --ts

When the app is deployed to render the build fails with the error message

It looks like you're trying to use TypeScript but do not have the required package(s) installed.

Please install typescript, @types/react, and @types/node by running:

yarn add --dev typescript @types/react @types/node

If if I move all “devDependencies” to “dependencies” in package.json the build succeeds. But this is not the correct behavior.

As specified in Specifying dependencies and devDependencies in a package.json file | npm Docs * "devDependencies": Packages that are only needed for local development and testing. This includes the typescript package and @type packages which should not be included in the final build.

Why does render require these “devDependencies” to be included in the build? This leads to a bloated build package and confusing implementation.

This is easily reproducible by creating a new NextJs app and deploying to render.

Render doesn’t require anything other than what your application references. Render by default doesn’t install devDependencies because if NODE_ENV is undefined by you it defaults to production, which doesn’t install devDependencies.

I don’t know much about TypeScript, it seems like their flow expects generated assets to be deployed, and not running the various TypeScript processes remotely. I disagree with this expectation, but I don’t have enough experience to be able to explain it nor refute it.

The takeaway that I generally give out continues to apply here: If you run TypeScript compilation processes on Render, it’s not a dev dependency.