mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Add check for writeable directory (#3370)
* Add check for writeable directory Followup of https://github.com/zeit/now-cli/issues/175 * Add link to docs
This commit is contained in:
parent
57c6f80d72
commit
8cd6bd3fc3
30
errors/build-dir-not-writeable.md
Normal file
30
errors/build-dir-not-writeable.md
Normal file
|
@ -0,0 +1,30 @@
|
|||
# Build directory not writeable
|
||||
|
||||
#### Why This Error Occurred
|
||||
|
||||
The filesystem does not allow writing to the specified directory. A common cause for this error is starting a [custom server](https://github.com/zeit/next.js#custom-server-and-routing) in development mode on a production server, for example, [now.sh](https://zeit.co) which [doesn't allow you to write to the filesystem after your app is built](https://zeit.co/docs/deployment-types/node#file-system-specifications).
|
||||
|
||||
#### Possible Ways to Fix It
|
||||
|
||||
When using a custom server with a server file, for example called `server.js`, make sure you update the scripts key in `package.json` to:
|
||||
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"dev": "node server.js",
|
||||
"build": "next build",
|
||||
"start": "NODE_ENV=production node server.js"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
and the custom server starts Next in production mode when `NODE_ENV` is `production`
|
||||
|
||||
```js
|
||||
const dev = process.env.NODE_ENV !== 'production'
|
||||
const app = next({ dev })
|
||||
```
|
||||
|
||||
### Useful Links
|
||||
|
||||
- [Custom Server documentation + examples](https://github.com/zeit/next.js#custom-server-and-routing)
|
14
readme.md
14
readme.md
|
@ -669,7 +669,19 @@ export default ({ url }) =>
|
|||
</ul>
|
||||
</details></p>
|
||||
|
||||
Typically you start your next server with `next start`. It's possible, however, to start a server 100% programmatically in order to customize routes, use route patterns, etc
|
||||
Typically you start your next server with `next start`. It's possible, however, to start a server 100% programmatically in order to customize routes, use route patterns, etc.
|
||||
|
||||
When using a custom server with a server file, for example called `server.js`, make sure you update the scripts key in `package.json` to:
|
||||
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"dev": "node server.js",
|
||||
"build": "next build",
|
||||
"start": "NODE_ENV=production node server.js"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This example makes `/a` resolve to `./pages/b`, and `/b` resolve to `./pages/a`:
|
||||
|
||||
|
|
|
@ -10,6 +10,14 @@ import md5File from 'md5-file/promise'
|
|||
export default async function build (dir, conf = null) {
|
||||
const buildId = uuid.v4()
|
||||
const buildDir = join(tmpdir(), uuid.v4())
|
||||
|
||||
try {
|
||||
await fs.access(buildDir, fs.constants.W_OK)
|
||||
} catch (err) {
|
||||
console.error(`> Failed, build directory is not writeable. https://err.sh/zeit/next.js/build-dir-not-writeable`)
|
||||
throw err
|
||||
}
|
||||
|
||||
const compiler = await webpack(dir, { buildId, buildDir, conf })
|
||||
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue