There are two options to develop with your local version of the codebase:
This will use the version of next
built inside of the Next.js monorepo. You can also let pnpm dev
run in a separate terminal. This will let you make changes to Next.js at the same time (note that some changes might require re-running pnpm next-with-deps
or pnpm next
).
If your app does not have dependencies, you can create a directory inside the monorepo (eg.: dev-app
) and run pnpm next ./dev-app
without creating a package.json
file.
If you already have an app and it has dependencies, you can follow these steps:
-
Move your app inside of the Next.js monorepo.
-
Run with
pnpm next-with-deps ./app-path-in-monorepo
-
Run
pnpm dev
in the background in the Next.js monorepo. -
In your app's root directory, run:
pnpm add ./path/to/next.js/{packages/next,node_modules/{react,react-dom}}
to re-install all of the dependencies and point
next
,react
andreact-dom
to the monorepo versions.Note that Next.js will be copied from the locally compiled version as opposed to being downloaded from the NPM registry.
-
Run your application as you normally would.
- If you see the below error while running
pnpm dev
withnext
:
Failed to load SWC binary, see more info here: https://nextjs.org/docs/messages/failed-loading-swc
Try to add the below section to your package.json
, then run again
"optionalDependencies": {
"@next/swc-linux-x64-gnu": "canary",
"@next/swc-win32-x64-msvc": "canary",
"@next/swc-darwin-x64": "canary",
"@next/swc-darwin-arm64": "canary"
},