address already in use for NODE_OPTIONS="--inspect"
Bug report
Describe the bug
No matter if run in Docker or on bare metal, if I set NODE_OPTIONS="--inspect" (with any arbitrary port) I get an error that it's in use.
To Reproduce
clone https://github.com/kasvtv/next-inspect
hit docker-compose up
Expected behavior
Starts normally
Screenshots
$ docker-compose up
Creating network "next-inspect_default" with the default driver
Building next-frontend
Step 1/5 : FROM node:12.8-alpine as install
---> 8fd54fb9eb5c
Step 2/5 : WORKDIR /app
---> Using cache
---> ab097ba91844
Step 3/5 : COPY ./package.json ./package-lock.json ./
---> Using cache
---> 5300a3cb2e05
Step 4/5 : RUN npm ci
---> Using cache
---> 9a0b9c1fc1ef
Step 5/5 : CMD npm run dev
---> Using cache
---> 219f9a9e0e58
Successfully built 219f9a9e0e58
Successfully tagged next-inspect_next-frontend:latest
WARNING: Image for service next-frontend was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating next-inspect_next-frontend_1 ... done
Attaching to next-inspect_next-frontend_1
next-frontend_1 | Debugger listening on ws://127.0.0.1:9229/34728af9-f6ce-4ea7-bbe0-e40437455b04
next-frontend_1 | For help, see: https://nodejs.org/en/docs/inspector
next-frontend_1 |
next-frontend_1 | > next-frontend@ dev /app
next-frontend_1 | > next
next-frontend_1 |
next-frontend_1 | Starting inspector on 127.0.0.1:9229 failed: address already in use
next-frontend_1 | npm ERR! code ELIFECYCLE
next-frontend_1 | npm ERR! errno 12
next-frontend_1 | npm ERR! next-frontend@ dev: `next`
next-frontend_1 | npm ERR! Exit status 12
next-frontend_1 | npm ERR!
next-frontend_1 | npm ERR! Failed at the next-frontend@ dev script.
next-frontend_1 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
next-frontend_1 |
next-frontend_1 | npm ERR! A complete log of this run can be found in:
next-frontend_1 | npm ERR! /root/.npm/_logs/2019-10-10T14_59_20_250Z-debug.log
next-frontend_1 | next-inspect_next-frontend_1 exited with code 12
System information
- OS: Windows
- Version of Next.js: see repo
Hi, it looks like you are setting NODE_OPTIONS='--inspect' for the whole environment, this means that when you run npm run dev it first attaches the inspect to the npm process and then tries to also attach it to the next process.
Instead you should be able to achieve this by removing it from the global environment and running NODE_OPTIONS='--inspect' node node_modules/.bin/next dev
I'm going to close this since it's not really a Next.js issue. If you are still having trouble feel free to reply with additional details
Thanks.
If anyone else runs into this issue, I've found a convenient way that allows you to run an npm script while keeping the inspect definition outside of that script:
npm --node-options=--inspect=0.0.0.0:9229 run dev
Seeing this error on Next.js v9.3.0
Using the solutions above does not work. The error persists.
I assume it's because Next.js has child processes and the --inspect flag is (implicitly?) passed to them.
edit: Found this: https://github.com/zeit/next.js/issues/11030 😅
I'm using Window 10 and Next.js v9.3.0
node --inspect-brk node_modules/next/dist/bin/next.js works
node node_modules/bin/next not work
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.