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

1.1 KiB

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 in development mode on a production server, for example, now.sh which doesn't allow you to write to the filesystem after your app is built.

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:

{
  "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

const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })