Azure / Azure/azure-functions-nodejs-worker

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

Open
#479 7 comments 0 reactions 0 assignees View on GitHub
App Service area:nodejs-functions enhancement P2
Dominant language
TypeScript
Stars
110
Forks
51
Avg merge
1d 1h
Merged PRs (30d)
2

Description

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://\.scm.azurewebsites.net/api/diagnostics/runtime):
```json

{
"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:

```shell
➜ 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
```

```typescript
import { AzureFunction, Context } from "@azure/functions"
const timerTrigger: AzureFunction = async function (context: Context, myTimer: any): Promise {
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
```

```log
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...

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.