Ensure folder exists for standalone server (#44745)
When using standalone output in a monorepo, nextjs will sometimes throw:
`> NX ENOENT: no such file or directory, open
'/dist/apps/my-app/.next/standalone/apps/my-app/server.js'`
next.config.js:
```js
const { withNx } = require("@nrwl/next/plugins/with-nx");
const path = require("path");
/**
* @type {import('@nrwl/next/plugins/with-nx').WithNxOptions}
**/
const nextConfig = {
output: "standalone",
experimental: {
outputFileTracingRoot: path.join(__dirname, "../../"),
},
};
module.exports = withNx(nextConfig);
```
## Bug
- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
Fixes https://github.com/nrwl/nx/issues/14112,
https://github.com/nrwl/nx/issues/9017
This `mkdir` instruction is the same as done for other parts of the
`copyTracedFiles` function. E.g. middlewares or pages.
Tested via publishing to an internal npm registry and pnpm overrides:
```json
"pnpm": {
"overrides": {
"next": "npm:@internal/next@13.1.3-dev"
}
}
```
Showing
Please
register
or
sign in
to comment