🐞 VSC TTK running Azure Function nested project ignores Node version in environment variable PATH (set via NVM) **SOLVED** #10785
Labels
investigating
needs attention
This issue needs the attention of a contributor.
TA:Compute
Team Area: Compute
Describe the bug
When using the VSC startup tasks on a project that includes an Azure Function for the backend, TTK doesn't respect if the user's environment is using NVM for Node with a supported version set at the default & rather defaults to
system
. If thesystem
version of Node that's installed isn't a valid version, it causes the Azure Function backend to enter a fail/crash/recycle loop making it unusable.If you manually run the startup task from the console (either within the integrated console in VSC or from your shell of choice), it works. BUT, if you run using the startup task Start Backend, it fails.
To Reproduce
Steps to reproduce the behavior:
Setup environment to use NVM
Install an Azure Functions-supported version of Node via NVM (ie: Node v18.19)
Install an unsupported version of Node via a Node.js provided installer (ie: Node v21.*)
Create a new TTK project: Tab > React with Fluent UI
Start the project using Run & Debug > Debug in Teams ([browser])
Once the build & deployment completes, pick [integrated Terminal] > Start Backend & observe sea of failures...
Kill the Node terminal (so ports aren't locked up)
In a new Terminal window, verify you have good versions of Node installed & configured via NVM.
Prove it's an issue with the custom task Start backend by manually running the exact same command the task runs from the API folder and observe it works this time compared to the first screenshot:
Expected behavior
The custom task Start backend from TTK respects the version of NVM in the envvar $PATH & not the one installed as system so it uses what the developer has set as their preference.
Screenshots
see above
VS Code Extension Information (please complete the following information):
CLI Information (please complete the following information):
Additional context
The only workaround I've figured out was to start the build, but before testing the app was to kill the Start Backend terminal/process, open a new process, and start the Azure Function project manually from the command line.
Furthermore...
This may not be a popular/widespread issue, but it will affect developers who use a package manager like Homebrew (macos) or chocolatey (windows)... which isn't uncommon.
The problem is these package managers, when a package has a dependency on Node.js, it installs upgraded versions of node using the provided Node.js installers. This installs Node in what Node version managers (NVM) recognize as system which are popular for developers.
The text was updated successfully, but these errors were encountered: