-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Labels
App ServiceThis would affect web apps as well as functionsThis would affect web apps as well as functionsP2enhancement
Milestone
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://<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 3import { 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 timerTrigger2021-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...
Metadata
Metadata
Assignees
Labels
App ServiceThis would affect web apps as well as functionsThis would affect web apps as well as functionsP2enhancement