wrong Version detected
Bug Report
-
Where did you experience the problem? Azure Web Apps
-
If your repo is publicly available please share its URL: private Repo
-
What happened? When trying to implement the Azure Api Backend, I experience an error during the building process.
Detected following platforms:
nodejs: 16.20.1
Version '16.20.1' of platform 'nodejs' is not installed. Generating script to install it...
Running 'npm install --production'...
npm WARN config production Use `--omit=dev` instead.
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '^=18.0' },
npm WARN EBADENGINE current: { node: 'v16.20.1', npm: '8.19.4' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@azure/[email protected]',
npm WARN EBADENGINE required: { node: '>=18.0' },
npm WARN EBADENGINE current: { node: 'v16.20.1', npm: '8.19.4' }
npm WARN EBADENGINE }
- What did you expect or want to happen? I set the engine version in the package.json to "node": "^18.16.0", but oryx doesn't seem to care.
package.json
{
"name": "api",
"version": "1.0.0",
"description": "",
"engines": {
"node": "^18.0"
},
"scripts": {
"start": "func start",
"test": "echo \"No tests yet...\""
},
"dependencies": {
"@azure/functions": "^4.0.0-alpha.7"
},
"devDependencies": {},
"main": "src/functions/*.js"
}
I also receive an error 404 when trying to reach the backend, but in my local env it's working flawlessly.
- How can we reproduce it? Create an Azure Function v4 HTTP-Trigger though the VS Code Extension in a .Node App.
@xXTim97Xx Hey there, thanks for filing this issue -- Oryx has existing logic that will capture the value provided to the engines.node field in an app's package.json file, and testing this locally, I can confirm it pulls down a version of the Node 18 binaries when this field is set to ^18.0 as you provided.
In your case, since you're going through Azure Functions, I believe they provide the --platform-version argument to the oryx build call they're making, so my initial hunch is that your app is targeting the Node 16 runtime stack and Azure Functions is providing --platform-version 16. Would you mind navigating to your Azure Function app in the Azure Portal, go to Settings > Configuration, select the General settings tab and verify that the Node.js version used is "Node.js 18 LTS"?
@cormacpayne Hey, thanks for your reply. But in my case, I'm using managed functions v4, following this tutorial: https://learn.microsoft.com/en-us/azure/static-web-apps/add-api?tabs=react So currently, I see no functions in the Azure Portal. Can I redirect the parameter somewhere else?
@xXTim97Xx taking a look at this document, there is a platform.apiRuntime property you can set in your staticwebapp.config.json file to define the API language runtime version for your application. In your case, you'd want to set this value to node:18, which will point your API application to a (public preview) version of Node 18.x supported by Static Web Apps.
{
...
"platform": {
"apiRuntime": "node:18"
}
...
}
Would you mind giving this a try and letting me know if you're able to see the application being built with Node 18?
Thank you so much. This is working and oryx has selected Node Version 18 now.
@xXTim97Xx thanks for the update, and glad to hear it's working now! 🥳