From cfe01d9e2dc17be7d8a00827eeb157ad4ef12e75 Mon Sep 17 00:00:00 2001 From: Andrew n marshall Date: Sat, 11 Jul 2020 01:37:36 -0700 Subject: [PATCH] Always check $PORT first Update npm dev scripts to always use -p PORT for dev and production run scripts. Uses the ${PORT:-3000} to fallback to using the standard 3000 port number. --- README.md | 16 ---------------- package.json | 4 ++-- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index c29a725..838f145 100644 --- a/README.md +++ b/README.md @@ -25,22 +25,6 @@ https://nextjs.herokuapp.com Once you have a [Next app working locally](https://nextjs.org/docs/#setup), you may deploy it for public access. -1. Revise the `npm start` script to set the [web listener `$PORT`](https://devcenter.heroku.com/articles/dynos#local-environment-variables): - - Merge this entry into **package.json**: - - ```json - { - "scripts": { - "dev": "next", - "build": "next build", - "start": "next start -p $PORT" - } - } - ``` - - ⭐️ *In March 2019, [Heroku began running `npm run build` automatically](https://devcenter.heroku.com/changelog-items/1573), so the old `heroku-postbuild` script entry is no longer required.* - 1. Ensure the app is a git repo, ignoring local-only directories: ```bash diff --git a/package.json b/package.json index 102eb93..05544eb 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,9 @@ "version": "1.0.0", "description": "Deploy Next.js server-side React apps to Heroku", "scripts": { - "dev": "next", + "dev": "next -p ${PORT:-3000}", "build": "next build", - "start": "next start -p $PORT" + "start": "next start -p ${PORT:-3000}" }, "engines": { "node": "10"