deno
deno copied to clipboard
NextJS Error - does not work using workspaces
Version: Deno 2.0.0
Summary
Installing NextJS works, and commands work normally, but when Next is made part of a workspace, running any commands (e.g. dev
, build
) all fail. Running on macOS.
Error
deno task build
Task build next build
▲ Next.js 14.2.15
Creating an optimized production build ...
<w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Can't resolve 'busboy' in '/Users/callum/Library/Caches/deno/npm/registry.npmjs.org/next/14.2.15'
<w> while resolving 'busboy' in /Users/callum/Library/Caches/deno/npm/registry.npmjs.org/next/14.2.15 to a directory
Failed to compile.
../../../../Library/Caches/deno/npm/registry.npmjs.org/next/14.2.15/dist/build/webpack/loaders/next-route-loader/index.js?kind=PAGES&page=%2F_error&preferredRegion=&absolutePagePath=next%2Fdist%2Fpages%2F_error&absoluteAppPath=next%2Fdist%2Fpages%2F_app&absoluteDocumentPath=next%2Fdist%2Fpages%2F_document&middlewareConfigBase64=e30%3D!
Error: Invariant: Expected relative import to start with "next/", found "14.2.15/dist/server/future/route-modules/pages/module.compiled"
at file:///Users/callum/Library/Caches/deno/npm/registry.npmjs.org/next/14.2.15/dist/build/load-entrypoint.js:36:19
at RegExp.[Symbol.replace] (<anonymous>)
at String.replaceAll (<anonymous>)
at loadEntrypoint (file:///Users/callum/Library/Caches/deno/npm/registry.npmjs.org/next/14.2.15/dist/build/load-entrypoint.js:28:17)
at Object.runMicrotasks (ext:core/01_core.js:672:26)
at Array.processTicksAndRejections (ext:deno_node/_next_tick.ts:57:10)
at eventLoopTick (ext:core/01_core.js:172:29)
at async loadPages (file:///Users/callum/Library/Caches/deno/npm/registry.npmjs.org/next/14.2.15/dist/build/webpack/loaders/next-route-loader/index.js:73:16)
at async Object.loader (file:///Users/callum/Library/Caches/deno/npm/registry.npmjs.org/next/14.2.15/dist/build/webpack/loaders/next-route-loader/index.js:115:24)
next/dist/client/components/not-found-error
Invariant: Expected relative import to start with "next/", found "14.2.15/dist/server/future/route-modules/app-page/module.compiled"
src/app/favicon.ico
Invariant: Expected relative import to start with "next/", found "14.2.15/dist/server/future/route-modules/app-route/module.compiled"
src/app/page.tsx
Invariant: Expected relative import to start with "next/", found "14.2.15/dist/server/future/route-modules/app-page/module.compiled"
> Build failed because of webpack errors
Reproduction
Install NextJS:
$ mkdir deno-next-workspace
$ cd deno-next-workspace
$ deno run -A npm:create-next-app@latest # install into 'next' directory
See that a regular build works:
$ cd next
$ deno task build # should see that build is successful
Convert into a workspace by creating deno.json
in the deno-next-workspace
directory:
$ cd ../
$ touch deno.json # file contents below
{
"workspace": [
"./next"
]
}
Run the build again and observe the error
$ cd next
$ deno task build # should see that build is unsuccessful
This is my firs time using Deno. Have been fighting with this issue for a bit today but still very impressed with what I've seen so far and looking forward to being able to use workspaces properly with my projects! Thanks to the team great work 🙏