Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Old npm version (1.1.37) on Windows Function App with Node.js runtime (v14.16.0) #479

Open
davidljuba15031979 opened this issue Nov 25, 2021 · 7 comments
Labels
App Service This would affect web apps as well as functions enhancement P2
Milestone

Comments

@davidljuba15031979
Copy link

In Azure Function App running in Windows OS with Node.js runtime in Azure Cloud, when Node.js version is v14.16.0, npm is very very old version 1.1.37.

It should be like this (Kudu App service https://<app-name>.scm.azurewebsites.net/api/diagnostics/runtime):

{
  "nodejs": [
    {
      "version": "14.16.0",
      "npm": "6.14.11"
    },

It is clearly shown by this code that npm version is wrong in runtime of Azure Function:

➜ az functionapp create \
        --name david-test-safe-to-delete-... \
        --resource-group ... \
        --subscription ... \
        --storage-account ... \
        --consumption-plan-location eastus \
        --disable-app-insights true \
        --os-type Windows \
        --runtime node \
        --runtime-version 14 \
        --functions-version 3
import { AzureFunction, Context } from "@azure/functions"
const timerTrigger: AzureFunction = async function (context: Context, myTimer: any): Promise<void> {
    const util = require('util');
    const exec = util.promisify(require('child_process').exec);
    try {
        await executeCommand("node --version");
        await executeCommand("npm --version");
    } catch (error) {
        context.log(`Function failed ${error}`)
    }

    async function executeCommand(cmd: string) {
        context.log("Starting showing logs using context.log command");
        context.log(`executeCommand("${cmd}")`);
        const { stdout, stderr } = await exec(cmd, { stdio: 'inherit' });
        context.log('stdout:', stdout);
        context.log('stderr:', stderr);
        context.log(`End showing logs using context.log command`);
    }
}
export default timerTrigger
2021-11-25T11:51:40.195 [Information] Starting showing logs using context.log command
2021-11-25T11:51:40.220 [Information] executeCommand("node --version")
2021-11-25T11:51:40.709 [Information] stdout: v14.16.0
2021-11-25T11:51:40.728 [Information] stderr:
2021-11-25T11:51:40.728 [Information] End showing logs using context.log command
2021-11-25T11:51:40.728 [Information] Starting showing logs using context.log command
2021-11-25T11:51:40.728 [Information] executeCommand("npm --version")
2021-11-25T11:51:41.628 [Information] stdout: 1.1.37
2021-11-25T11:51:41.644 [Information] stderr:
2021-11-25T11:51:41.644 [Information] End showing logs using context.log command

I can not execute some npm scripts because npm is not working as expected...

@ghost ghost assigned soninaren Nov 25, 2021
@davidljuba15031979 davidljuba15031979 changed the title Old npm version (1.1.37) on Windows Function App with Node runtime (v14.16.0) Old npm version (1.1.37) on Windows Function App with Node.js runtime (v14.16.0) Nov 25, 2021
@davidljuba15031979
Copy link
Author

I tried in Azure Function App Linux and everything works:

➜ az functionapp create \
        --name david-test-safe-to-delete-... \
        --resource-group ... \
        --subscription ... \
        --storage-account ... \
        --consumption-plan-location eastus \
        --disable-app-insights true \
        --os-type Linux \
        --runtime node \
        --runtime-version 14 \
        --functions-version 3
➜ func azure functionapp publish \  
        david-test-safe-to-delete-... \
        --publish-local-settings \                  
        --overwrite-settings \
        --build remote
2021-11-25T18:41:08Z   [Information]   Starting showing logs using context.log command
2021-11-25T18:41:08Z   [Information]   executeCommand("node --version")
2021-11-25T18:41:08Z   [Information]   stdout: v14.18.0
2021-11-25T18:41:08Z   [Information]   stderr: 
2021-11-25T18:41:08Z   [Information]   End showing logs using context.log command
2021-11-25T18:41:08Z   [Information]   Starting showing logs using context.log command
2021-11-25T18:41:08Z   [Information]   executeCommand("npm --version")
2021-11-25T18:41:09Z   [Information]   stdout: 6.14.15
2021-11-25T18:41:09Z   [Information]   stderr: 
2021-11-25T18:41:09Z   [Information]   End showing logs using context.log command

Logs from remote build during deployment of function:

Running oryx build...
Command: oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform nodejs --platform-version ~14
Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
You can report issues at https://github.com/Microsoft/Oryx/issues

Oryx Version: 0.2.20201015.1, Commit: 1a35fbce482b20b71290f3a837a3469803ce4b44, ReleaseTagName: 20201015.1

Build Operation ID: |iPWYEO88TOU=.913933d5_
Repository Commit : d15cc7a8141f40579fed9d44c1a87b81

Detecting platforms...
Detected following platforms:
  nodejs: 14.17.6
Version '14.17.6' of platform 'nodejs' is not installed. Generating script to install it...


Source directory     : /tmp/zipdeploy/extracted
Destination directory: /home/site/wwwroot


Downloading and extracting 'nodejs' version '14.17.6' to '/tmp/oryx/platforms/nodejs/14.17.6'...
Downloaded in 1 sec(s).
Verifying checksum...
Extracting contents...
Done in 2 sec(s).


Using Node version:
v14.17.6

Using Npm version:
6.14.15

Running 'npm install --unsafe-perm'...

@v-bbalaiagar v-bbalaiagar self-assigned this Nov 26, 2021
@davidljuba15031979
Copy link
Author

davidljuba15031979 commented Nov 26, 2021

//...
    try {
        await executeCommand("node --version");
        await executeCommand("where node");
        await executeCommand("npm --version");
        await executeCommand("where npm");
        await executeCommand("npm run ...");
    } //...
//...
2021-11-27T06:39:28.733 [Information] Starting showing logs using context.log command
2021-11-27T06:39:28.766 [Information] executeCommand("node --version")
2021-11-27T06:39:29.342 [Information] stdout: v14.16.0
2021-11-27T06:39:29.371 [Information] stderr:
2021-11-27T06:39:29.371 [Information] End showing logs using context.log command

2021-11-27T06:39:29.371 [Information] Starting showing logs using context.log command
2021-11-27T06:39:29.371 [Information] executeCommand("where node")
2021-11-27T06:39:30.028 [Information] stdout: C:\Program Files (x86)\nodejs\14.16.0\node.exe
C:\Program Files (x86)\nodejs\node.exe
2021-11-27T06:39:30.069 [Information] stderr:
2021-11-27T06:39:30.069 [Information] End showing logs using context.log command

2021-11-27T06:39:30.069 [Information] Starting showing logs using context.log command
2021-11-27T06:39:30.069 [Information] executeCommand("npm --version")
2021-11-27T06:39:31.269 [Information] stdout: 1.1.37
2021-11-27T06:39:31.297 [Information] stderr:
2021-11-27T06:39:31.298 [Information] End showing logs using context.log command

2021-11-27T06:39:31.298 [Information] Starting showing logs using context.log command
2021-11-27T06:39:31.298 [Information] executeCommand("where npm")
2021-11-27T06:39:31.927 [Information] stdout: C:\Program Files (x86)\nodejs\npm
C:\Program Files (x86)\nodejs\npm.cmd
2021-11-27T06:39:31.960 [Information] stderr:
2021-11-27T06:39:31.960 [Information] End showing logs using context.log command

When npm error occurs, message is:

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "..."
npm ERR! cwd C:\home\site\wwwroot\...\...\...
npm ERR! node -v v0.6.20
npm ERR! npm -v 1.1.37
npm ERR! code ELIFECYCLE

So it clearly shows that something is wrong with node and npm versions on Windows Azure Function App for Typescript

@v-bbalaiagar
Copy link

Hi @davidljuba15031979, Thank you for your feedback! We will check for the possibilities internally and update you with the findings.

@v-bbalaiagar v-bbalaiagar transferred this issue from Azure/azure-functions-host Nov 29, 2021
@v-bbalaiagar
Copy link

Transferred this issue to nodejs repo for further investigation.
Hi @AnatoliB, Can you kindly look into this.

@Enngage
Copy link

Enngage commented Feb 11, 2022

Running into this as well :/ Using Typescript Azure Functions and tried using Node.js 12/14/16 as well as Azure functions 2,3/4, all with the same result where npm is on version 1.1.37 and I can't seem to update it.

Also using windows functions.

@ejizba
Copy link
Contributor

ejizba commented Feb 28, 2022

As a workaround, you can hardcode the path to the npm version you want. However, we make NO guarantees that this version/path will continue to exist. Practically speaking, though, its relatively stable and I can't remember a time where we've removed npm versions. Here's an example using the above sample code:

executeCommand('"%ProgramFiles(x86)%/npm/8.1.0/npm" --version')

I think this is a "feature request" as opposed to a "bug" for two reasons:

  1. The behavior has always been this way, so it's not a regression
  2. We have not made any guarantees about npm versions on a user's app. We have some guarantees about Node versions (a few docs here, here and here), but none of them mention npm.

All that being said, 1.1.37 is super old and I hope we can address this soon. This is the first issue I'm aware of asking about running npm as a child process, but it seems like a valid scenario so I'm a bit surprised no one has asked for it before. I propose we ensure the version of npm matching the user's version of Node.js is on the PATH. I don't think we want to support any sort of specific version pinning of npm like we do for node. In any case, we should update the docs based on our decision.

Lastly, I confirmed this behavior is the same for Azure web apps, meaning it'll have to be done at the App Service-level, not just for Functions (which adds some overhead involving other teams).

@ejizba ejizba added the App Service This would affect web apps as well as functions label Mar 16, 2022
@ejizba ejizba modified the milestones: Backlog Candidates, Tracking Mar 21, 2022
@martinlingstuyl
Copy link

Same problem here, running an Azure Function app on Azure on Windows and the PowerShell stack. I configured Node to version 18, using the app setting. The npm version keeps sticking to 1.x.

When will this be fixed? Even if it's not a regression, it seems to me that it's not desirable behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
App Service This would affect web apps as well as functions enhancement P2
Projects
None yet
Development

No branches or pull requests

7 participants