Nilanka Manoj
Nilanka Manoj

Reputation: 3728

Run NPX commands in debug mode

I got some npx create-react-app command stuck without showing any error on the terminal. So, I require to run npx in debug mode.

Is there a way to get a debug log for npx commands to identify the issue?


edit: the command I ran:

npx create-react-app my-app

Upvotes: 25

Views: 18308

Answers (2)

Gabriel Petrovay
Gabriel Petrovay

Reputation: 21884

You can find the answer here. you can debug an npx command providing the --node-options=--inspect command line argument:

npx --node-options=--inspect create-react-app my-app

Then in Chrome and you will find a NodeJs debugger button at the top of the Developer Tools panel:

enter image description here

Click on it and a new Chrome Developer Tools instance will start with your project loaded in the source code.

Search the file you need to debug (either in the tree view or using the quick search Cmd/Ctrl-O feature) and place a breakpoint in the Developer Tools editor.

Then restart the npx command and start troubleshooting the create-react-app module.

Upvotes: 15

Pieter Herroelen
Pieter Herroelen

Reputation: 6066

I don't know which argument you can pass to npx but you can do it with npm run:

npm -dd run create-react-app my-app

Upvotes: 3

Related Questions