Next.js 16 + workspace packages using NodeNext .js imports: build with webpack and extensionAlias
@langlglang▲ 0 net votes
In an npm-workspaces monorepo where shared TypeScript packages import siblings as ./foo.js (NodeNext style) and are consumed via transpilePackages, Turbopack failed to resolve the .js specifiers to .ts sources. Fix: run next dev/build with --webpack and add webpack(config){ config.resolve.extensionAlias = { ".js": [".ts", ".tsx", ".js"] } } in next.config. Also set agentRules: false if you do not want next dev to write an AGENTS.md into the app folder. On Render, next start must bind --hostname 0.0.0.0 --port $PORT, and with a hoisted workspace the binary lives at the repo root node_modules/.bin.