Azure Deployment Angular .NetCore - node.js

I have a project .NetCore Angular and i try to publish it on azure using FTP.
Once the FTP is done publishing the files, and i access the website i am getting an error
npm ERR! node -v v0.6.20
npm ERR! npm -v 1.1.37
Please take note on my local environment i am using node version 12.14.0
I am suspecting the error happens of my node version on my Azure Enviroment. My Question right now,is that how do i update
node version on my azure environment.
Thanks In advance.
Sincerely yours,
Pong

You can set the WEBSITE_NODE_DEFAULT_VERSION in the portal by checking the nodejs version from D://program files(x86)/nodejs.-
From all the available versions, choose one and update WEBSITE_NODE_DEFAULT_VERSION. Also keep in mind that Azure Functions runtime v1(~1) locks your node version at v6.11.
To use a configurable Node.js runtime, you'll, need to upgrade your Functions runtime to v2.x:
Go through this doc for more reference : NodeJS Version reference doc

Related

azure function app console - npm install doesn't work. Couldn't install agentkeepalive

I need to install agentkeepalive in azure functions. I was able to install other packages an hour ago. But as soon as I tried to install agentkeepalive, it doesn't honour any npm install command nor return any error messages in the console.
I tried this Cannot find module 'agentkeepalive' when updating NPM to 7.20.3 it is not working.
I restarted the azure function app and tried to install the package, no luck. Now I couldn't install any package.
Help in installing the packages from this console. Thanks.
In the Azure App Service Editor, the latest version will be 6.14.* because in app services the latest node version is 14v and the node.js 14 LTS npm latest version is 6.14.*. So though you try installing the latest version the npm still remains 6.14.*.
To install the npm install -g npm#7.20.3, it needs more than {"node":">= 8.0.0"}.
For doing that you need to update few settings from the Azure portal > <your-function-app> > configuration > settings tab from left pane. Below are the settings :
Name : `WEBSITE_NODE_DEFAULT_VERSION`
Value : 14.15.0
Name : `WEBSITE_RUN_FROM_PACKAGE`
Value : 0 [If published functions already]
Name : `FUNCTIONS_EXTENSION_VERSION`
Value : beta [optional]
Even if you update npm to the latest version, it will stay to the last version release i.e., 6.14.*
Also, try changing your node version in your Azure App service for getting compatible error-free npm versions upgrade.
Below are the references for the NPM-Node Compatibility release versions to Azure App Services (Editor - Preview).
REFERENCES :
Azure Functions Support for node.JS 14 and .Net 5 Is Generally Available.
Node.js version 12.14.x be available on Azure App Services.
I changed the node.js version in the azure portal and it started working. I think it just hung somewhere. Changing the version re-enabled or caused node.js restart. Here's the image attached.

Azure DevOps self hosted agent reports wrong version for NPM

We have updated Node to version 10.16.3 and NPM to version 6.11.3 (all the latest at this time) on our Windows based self hosted agent.
However, in a job run logs, we see that the agent reports version 6.9.0 for NPM, which is the default version for Node 10.16.3 installation.
Inside the VM where the hosted agent is, if I run 'npm' in the CMD, I get the latest version for NPM. Also, if I run the same command that the agent is running to get the version, I still get the correct version for NPM:
What could be wrong here?
The reason we want the latest version of NPM is because our builds run faster with it.
Thank you!
We have had a very amateur approach to this problem. When we are logging in through RDP, we are using the user 'agent' and all installations are scoped to that user. However, the agent is using the NetworkService user, which has its own scope for NPM and Node.
The fix was basically to add step in our build pipeline to check for latest version of NPM and install it in case it is not installed.
Yeah, I got caught out by this too. Because it runs under the NetworkService account, it can't read the global folder, so has it's own little copy/cache at
C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\npm
My easiest way to get back up and running, was to just manually upgrade the npm at that location using the following command:
npm install --prefix C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\npm npm

Node app in Azure App Service npm install timeout even for single packages no matter what, extremely unreliable

I have a standard Azure App Service and I'm trying to run a node rest api from it. I've had nothing but troubles from the very start.
Going into kudu to check what node versions are supported, the only supported node version listed is "nodejs":[{"version":"0.10.40" but I added the env variable where I specified node version 8.4 and it seems to be supported and when I run node --version it gives me 8.4 but that kudu config hasn't changed.
For some reason -- it doesn't install the packages right, I looked for 'body-parser' in the node_modules folder and it is not there even if its listed in package.json as direct dependency.
Running npm install or npm install body-parser all time-out with no real reason.
Running npm install as part of the devops release deployment cycle runs in 17 secondsbut it ends up saying 'up to date'
Judging by the mismatches between kudu's runtime file, the node version mismatch I think there's something seriously wrong with my app's config.
I'm running off a pay-as-you-go subscription using the Basic tier with 100 units.
This is a freshly installed app powering absolutely nothing.
First, please make sure that you have set the WEBSITE_NODE_DEFAULT_VERSION value in tab Application settings tab of your WebApp on Azure portal to enable the Node version what you want, as the figure below to use Node version 10.14.1.
Then, you can check it via commands node -v & npm -v in Kudu console.
I tried to install body-parser package in the directory node-test created by me via command npm install body-parser. Although there is some warn messages due to missing some files like package.json, the body-parser package has existed under the node-modules.

Azure node deployment - Service Unavailable - npm WARN lifecycle

I'm using git to deploy a node.js app to Azure App Service.
It returns
Service Unavailable
on the app page. In the console it shows
Failed to load resource: the server responded with a status of 503
(Service Temporarily Unavailable)
During the deployment I get one warning:
npm WARN lifecycle The node binary used for scripts is /usr/bin/node but npm is using /opt/nodejs/8.1.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
I included the option in scripts in package.json but it didn't solve it, perhaps it's the wrong place?
"start": "node server/server.js --scripts-prepend-node-path"
I've googled for an answer but couldn't solve it.
How to npm configuration options (such as --scripts-prepend-node-path) when deploying to azure web sites?
Setting WEBSITE_NODE_DEFAULT_VERSION to 8.1.0 in the environment variables didn't help. I have this node version specified in package.json.
I wasn't able to do a Custom Deployment Script as the second hint suggests.
I ran npm config set scripts-prepend-node-path true locally in the project folder and then pushed but it didn't solve it.
Some other answers suggested that an app might need to be scaled up, but this one is handled well by Heroku free plan and here on Azure I have a student plan.
I'm including a part of the log I got:
Detecting node version spec...
Using package.json engines.node value: 8.1.0
Node.js versions available on the platform are: 4.4.7, 4.5.0, 6.2.2, 6.6.0, 6.9.3, 6.10.3, 6.11.0, 8.0.0, 8.1.0.
Resolved to version 8.1.0
Detecting npm version spec...
Using default for node 8.1.0: 5.0.3
NPM versions available on the platform are: 2.15.8, 2.15.9, 3.9.5, 3.10.3, 3.10.10, 5.0.3.
Resolved to version 5.0.3
Running "/opt/nodejs/8.1.0/bin/node" "/opt/npm/5.0.3/node_modules/npm/bin/npm-cli.js" install --production
npm WARN lifecycle The node binary used for scripts is /usr/bin/node but npm is using /opt/nodejs/8.1.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
npm WARN node_code#1.0.0 No description
updated 17 packages in 29.222s
npm WARN node_code#1.0.0 No repository field.
Finished successfully.
Diagnosing the app on Azure resulted in:
Failed Urls 50% of failures came from '/favicon.ico' path.
I would be really grateful if anyone could help me out with this, I'm new to such deployments. If I didn't provide some necessary data, please let me know.
Thank you
Based on my understanding, this is not about deployment issue. The 503 Service Unavailable error means the web site's server is simply not available right now. This problem is often caused by application level issues, such as:
requests taking a long time
application using high memory/CPU
application crashing due to an exception.
You can check out Azure's official documentation to troubleshoot HTTP errors of "502 bad gateway" and "503 service unavailable" in your Azure web apps.

How to use latest npm on Azure Mobile Service deployment

The Azure Mobile Service image that I am using currently is locked down to npm version 1.2.30. There are latest npm version installed on the image(under ...\Program Files(x86)\npm). But npm is locked down to the version 1.2.30 due to the reason that it was installed with node.js(under ...\Program Files(x86)\nodejs) AND the path always looks under \nodejs\ folder first and uses it.
This is causing me problem in using some npm packages (including googleapis) on deployment. The errors appear while installing googleapis are bugs in older version of npm and are resolved in latest.
The simplest solution is to delete the 'npm' file and 'npm.cmd' file under ...\Program Files(x86)\nodejs\ folder so that the npm is read from ..\Program Files(x86)\npm\ folder. But i get access denied errors while trying to access these files. I am accessing the mobile service image through Kudu interface.
Is there are work-around for this?
For upgrading npm, you can follow the instructions from David Ebbo on this forum post: https://social.msdn.microsoft.com/Forums/azure/en-US/068ef026-f80d-4bf8-9f40-5d1af33a1024/git-deployment-fails-with-npm-error-when-resolving-a-package-version-containing-a-?forum=windowsazurewebsitespreview

Resources