madskristensen / NpmTaskRunner

Visual Studio extension
Other
88 stars 32 forks source link

NPM Script works via terminal but does not work via extension #98

Open Mattwmaster58 opened 3 months ago

Mattwmaster58 commented 3 months ago

Describe the bug I have a NPM task npm run watch. When running the task via Task Explorer:

C:\{path}> cmd.exe /c npm run watch --color=always
> production@0.1.0 watch
> node_modules/.bin/webpack --watch --mode development
'node_modules' is not recognized as an internal or external command,
operable program or batch file.
Process terminated with code 1.

When running within the terminal:

**********************************************************************
** Visual Studio 2022 Developer PowerShell v17.10.1
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
PS C:\> cd {path}
PS C:\{path}> cmd.exe /c npm run watch --color=always

> production@0.1.0 watch C:\{path}
> webpack --watch --mode development

Browserslist: caniuse-lite is outdated. Please run:
.... etc

(works)

Since Task Explorer is running from the same working directory, I would expect this to work fine, but it doesn't and it's unclear why. To Reproduce Steps to reproduce the behavior:

  1. Define a custom NPM script:
    "scripts": {
        "watch": "node_modules/.bin/webpack --watch --mode development"
    },

    Expected behavior Works

Additional context Admittedly the script is a bit non-standard, but developers are often in a situation where they are unable to change this sort of thing.

InspiredEnigma12477 commented 3 months ago

I have aslo faced similar issue and one of the observations is it has been Visual Studio version 16.x it works but after upgraded to 17.x

started facing these issue

https://github.com/madskristensen/NpmTaskRunner/issues/87#issuecomment-2175161651