1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/errors/build-dir-not-writeable.md
Tim Neutkens 8cd6bd3fc3
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
2017-12-02 18:13:39 +01:00

31 lines
1.1 KiB
Markdown

# 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)