如何以Inspect模式启动jscodeshift?启动地址占用报错咨询
node --inspect-brk + jscodeshift That error message spells out the core issue loud and clear: the default Node.js inspector port (9229) is already being used by another process, so jscodeshift can’t spin up its own inspector instance. Let’s walk through simple, actionable fixes to get you back to running your script:
1. Kill the process hogging port 9229
First, identify which process is holding onto the port:
- macOS/Linux: Run this in your terminal to find the process ID (PID):
Then kill it with:lsof -i :9229kill -9 <PID> - Windows: Open Command Prompt and run:
Grab the PID from the last column, then terminate the process forcefully:netstat -ano | findstr :9229taskkill /PID <PID> /F
2. Use a custom port for the inspector
If you don’t want to kill the existing process, just tell Node to use an unused port instead of 9229. Modify your command like this (replace 9230 with any free port):
node --inspect-brk=9230 ./node_modules/.bin/jscodeshift mod.js file
You’ll just need to point your debugger to this new port when connecting.
3. Clean up stray debug processes
Occasionally, a previous Node debugging session might hang in the background without exiting properly. If killing the port process doesn’t work, try restarting your terminal or checking your system’s process manager for any leftover Node.js instances.
内容的提问来源于stack exchange,提问作者user2167582

