Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run NPX commands in debug mode

Tags:

debugging

npx

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
like image 555
Nilanka Manoj Avatar asked Apr 14 '20 15:04

Nilanka Manoj


People also ask

How do I run a command in debug mode?

For debugging multiple instances of your application you can launch them separately from the command line (or press Ctrl+F5 in VS to launch the application without debugger attached) and then attach the VS debugger manually using the Debug -> Attach to Process... menu command.

Can you debug NPM?

The npm debug package provides a strong and selective debugging method to improve the code and remove console. log statements from the application as it can be used in different files by using it with different keys like myapp:server for server file, myapp:user for user file, etc.

How do you start a debug session in VS code?

To bring up the Run and Debug view, select the Run and Debug icon in the Activity Bar on the side of VS Code. You can also use the keyboard shortcut Ctrl+Shift+D. The Run and Debug view displays all information related to running and debugging and has a top bar with debugging commands and configuration settings.

How to debug NPX command in chrome?

You can find the answer here. you can debug an npx command providing the --node-arg=--inspect command line argument: Then in Chrome and you will find a NodeJs debugger button at the top of the Developer Tools panel:

What is NPX in NPM?

npx is a very powerful command that's been available in npm starting version 5.2, released in July 2017. If you don't want to install npm, you can install npx as a standalone package npx lets you run code built with Node.js and published through the npm registry.

How do I use NPM debug port?

If you have defined an npm debug script in your package.json, you can use it directly from your launch configuration. Make sure that the debug port used in the npm script, corresponds to the port specified in the snippet. Attach: Attach to the debug port of a locally running Node.js program.

How do I launch a node Program in debug mode?

Launch via npm: Launch a Node.js program through an npm 'debug' script. If you have defined an npm debug script in your package.json, you can use it directly from your launch configuration. Make sure that the debug port used in the npm script, corresponds to the port specified in the snippet.


Video Answer


2 Answers

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

like image 177
Pieter Herroelen Avatar answered Oct 19 '22 21:10

Pieter Herroelen


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.

like image 1
4 revs, 2 users 76% Avatar answered Oct 19 '22 20:10

4 revs, 2 users 76%