File size: 1,801 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# Developing Using Your Local Version of Next.js
There are two options to develop with your local version of the codebase:
## Develop inside the monorepo
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:
1. Move your app inside of the Next.js monorepo.
2. Run with `pnpm next-with-deps ./app-path-in-monorepo`.
## Set as a local dependency in `package.json`
1. Run `pnpm dev` in the background in the Next.js monorepo.
2. In your app's root directory, run:
```sh
pnpm add ./path/to/next.js/{packages/next,node_modules/{react,react-dom}}
```
to re-install all of the dependencies and point `next`, `react` and `react-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.
3. Run your application as you normally would.
### Troubleshooting
- If you see the below error while running `pnpm dev` with `next`:
```
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.
```json
{
"optionalDependencies": {
"@next/swc-linux-x64-gnu": "canary",
"@next/swc-win32-x64-msvc": "canary",
"@next/swc-darwin-x64": "canary",
"@next/swc-darwin-arm64": "canary"
}
}
```
|