Serge van den Oever's weblog

Run npm NodeJS scripts with Fiddler

Tue Feb 25 2020 • ☕️ 1 min read • you like my writing? Buy me a coffee

When Fiddler is started, it uses the http://localhost:8888 by default as the proxy port. If this port is taken you will see the following message:

Fiddler Port in Use

To see the port used by Fiddler, go to Tools –> WinINET Options... –> LAN settings –> Advanced

Now create the Powershell script fiddler-npmscript.ps1 next to your package.json file:

param(
    [string]$NpmScript = "watch", 
    [int]$ProxyPort = 8888
)

$env:https_proxy="http://localhost:$ProxyPort"
$env:http_proxy="http://localhost:$ProxyPort"
$env:NODE_TLS_REJECT_UNAUTHORIZED=0
npm run $NpmScript

This script can be called as .\fiddler-npmscript.ps1 when using the watch script with the default proxy port 8888.

When using for example the build script on port 2046 call the script as .\fiddler-npmscript.ps1 build 2046.

Discuss on TwitterEdit on GitHub

This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. You are free to share and adapt this work for non-commercial purposes, provided you give appropriate credit, provide a link to the license, and indicate if changes were made. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/.

Serge van den Oever's weblog

Serge van den Oever

Personal blog by Serge van den Oever - als je maar lol hebt...
X: @svdoever
LinkedIn: Serge van den Oever - articles on LinkedIn
GitHub: svdoever

Technology Consultant @ Macaw
2021-2024 Sitecore Technology MVP