Azure App Service: node version in package.json do not work - azure

in my node js web app, i use node version = 6.9.1:
"engines": {
"node": "6.9.1"
}
and when i do deployment with
git push azure master
it shows correct node is used.
...
remote: Selected node.js version 6.9.1. Use package.json file to choose a different version.
remote: Selected npm version 3.10.8
...
but my app service is not started correctly because of node.exe crashed.
later i output the used node version number in my entry point script, i get
Node version:v0.6.20
from file D:\home\LogFiles\Application\xxxx-stdout-xxxx.txt
so obviously Azure App service is not using my defined version of node.exe.
later i follow https://learn.microsoft.com/en-us/azure/nodejs-specify-node-version-azure-apps
add below text in file D:\home\site\wwwroot\iisnode.yml to fix this issue.
nodeProcessCommandLine: "D:\Program Files (x86)\nodejs\6.9.1\node.exe"
so my question is why Azure App Service (iisnode) is not using my defined node version in package.json ?

To change the NodeJs version of Azure App Service by using iisnode.yml(which won’t change node version on kudu cli or during deployment), you need to set iisnode.yml file manually in your app root folder with including below line as you have mentioned:
nodeProcessCommandLine: "D:\Program Files (x86)\nodejs\5.9.1\node.exe"
Then you need to set iisnode.yml file using package.json during source control deployment.
Azure Source Control deployment process would involve below steps
1. Moves content to azure web app
2. Creates default deployment script, if there isn’t one(deploy.cmd, .deployment files) in web app root folder
3. Run’s deployment script where it creates iisnode.yml file if you mention nodejs version in package.json file > engine
Reference: https://blogs.msdn.microsoft.com/azureossds/2016/04/20/nodejs-and-npm-versions-on-azure-app-services/.
Or else you can use App Settings in Azure portal to change the version of NodeJs.

Related

/npm/bin/npm-cli.js: not found on Azure app service - node app

I am trying to deploy the nodejs app to Azure but I am getting the below error.
2021-07-08T10:22:38.234570707Z
/home/site/wwwroot/node_modules/.bin/npm: 1:
/home/site/wwwroot/node_modules/.bin/npm: ../npm/bin/npm-cli.js: not
found
2021-07-08T10:22:38.244796509Z npm info lifecycle express-typescript-starter#0.1.0~start: Failed to exec start script
This is the output I am seeing application logs on Azure.
App Service is the free plan with Node 14 as a runtime environment running on Linux. I have verified all the files, everything looking good.
Even I checked node modules as well. The folder is there but the error-specific file i.e inside node_module npm/bin/npm-cli.js. It is not there.
But it's not on my local as well and there it's working fine.
I am deploying through Github action.

gcloud app deploy failed with error - gcloud crashed FileNotFoundError - python3 app

I am trying to deploy a sample python app which I got from another tutorial. However, the deployment fails as below:
gcloud app deploy Beginning deployment of service [default]... ERROR:
gcloud crashed (FileNotFoundError): [Errno 2] No such file or
directory:
'/Users/nileshdeshmukh/Desktop/Training/Python/FlaskIntroduction-master/env/.Python'
My app.yaml file is as below:
runtime: python3
env: standard
runtime_config:
python_version: 3
I have all dependencies copied in env/bin but the build process is looking for env only..
I think the problem would be solved if the deployment process looks at env/bin, but don't know how to force it to look at given path
The runtime_config setting is for App Engine flex only and isn't needed for App Engine Standard. You can safely remove it.
As per the error, you should ensure that all your dependencies are self-contained and shipped with your app or listed in your requirements.txt file.
Be careful, some gcloud commands use .gitignore file to prevent sending useless file to Cloud for building your app.
You can override this behavior by creating a .gcloudignore file. Same syntax as git ignore but take into account only by gcloud commands and not by git. By the way you can differentiate the file to send to the cloud and file to send to git

ERROR: (gcloud.app.deploy) could not be identified as a valid source directory or file

I get this error every time I run the gcloud app deploy command.
My app.yaml is in the same directory as where manage.py is.
I am also not working from Local disk C, am working from Local disk G and using Visual studio code cmd terminal.
ERROR: An app.yaml (or appengine-web.xml) file is required to deploy this directory as an App Engine application. Create an app.yaml file using the directions at https://cloud.google.com/appengine/docs/flexible/python/configuring-your-app-with-app-yaml (App Engine Flexible Environment) or https://cloud.google.com/appengine/docs/standard/python/config/appref (App Engine Standard Environment) under the tab for your language.
ERROR: (gcloud.app.deploy) [G:\] could not be identified as a valid source directory or file.
From what I can understand, you are running the "gcloud app deploy" command from the main folder of your G: local disk.
In order to deploy the app, your path should be the one that the app.yaml file is in or specify the path as a parameter as shown here in the first example when you run the "gcloud app deploy".
You are wrong the directory.
To make sure app.yaml path, you can include it into command line as below:
gcloud --quiet --project $PROJECT_ID app deploy app.yaml

Cloudfoundry : Cannot push NodeJS app to Bluemix

I am trying to push Kibana
https://www.elastic.co/products/kibana
to Bluemix PaaS via cloudfoundry. At cf push i get this error
Error uploading application.
GetFileAttributesEx C:\Users\asd\qwe\zxc\installedPlugins\shield\node_modules\eslint\node_modules\file-entry-cache\node_modules\flat-cache\node_modules\del\node_modules\globby\node_modules\glob\node_modules\inflight\node_modules\wrappy\package.json: The system cannot find the path specified.
i can see that the package.json is actually present at that path! How do i resolve this?
cf --version
cf version 6.12.4-b4b6af1-2015-09-18T10:55:12+00:00
The error is due to the file path being too long. Add the node_modules directory to a .cfignore file in the app's root directory and then push again. The node_modules won't be uploaded and will instead be installed as part of the staging process.
See https://github.com/IBM-Bluemix/nodejs-cloudant/blob/master/.cfignore for an example .cfignore.
You could also switch to npm v3 which keeps the node_modules directory flatter, but you still wouldn't normally push it with your app.

Upgrading Node on an Azure website?

I'm trying to run some pre deployment tasks (unit tests etc) with NPM on an Azure website, however the version of node on the VM is v0.10.32, the current version of node is v4.2.4.
I have non administrative access to the command line via the SCM website, no RDP etc.
Is there any way to upgrade?
Ensure the Azure Web App has the node version you want.
Go to yoursite.scm.azurewebsites.net
Choose Debug Console (PowerShell or CMD)
Navigate to D:\Program Files (x86)\nodejs
Run dir to see the available nodejs versions.
For instance, if there is a directory named 6.3.0, then you can use it.
// App Setting
WEBSITE_NODE_DEFAULT_VERSION 6.3.0
// package.json
engines":{"node": "6.3.0"}
You can specify the version of node that the app is running on using the package.json file. Add:
"engines":{"node":version}
e.g.:
"engines":{"node": "0.12.x"},
More info: https://azure.microsoft.com/en-us/documentation/articles/nodejs-specify-node-version-azure-apps/
2017 update. All above didn't work for me in.
I changed:
// package.json
engines":{"node": "8.0.0"}
and then I added app settings value
<appSettings>
<add key="WEBSITE_NODE_DEFAULT_VERSION" value="8.0.0" />
</appSettings>
I restarted an app million times, and the solution was to change iisnode.yml
nodeProcessCommandLine: "D:\Program Files (x86)\nodejs\8.0.0\node.exe"
That's it. I hope it will help someone.
Update
Just to clarify things: I'm talking about App Service
And if you ftp to your App you will see iisnode.yml here:
Changing NodeJs Version in Azure Portal
Navigate to your web app in azure portal
Click on Application settings in Settings blade.
You can include WEBSITE_NODE_DEFAULT_VERSION as key and version of nodejs you want as value in app settings.
Example: WEBSITE_NODE_DEFAULT_VERSION 8.0.0
For me, the solution was neither to set the engine version in package.json, nor to set WEBSITE_NODE_DEFAULT_VERSION, but to use the az command line as described here:
az webapp config set \
--resource-group <resource-group-name> \
--name <app-name> \
--linux-fx-version "NODE|14-lts"

Resources