Azure node deployment - Service Unavailable - npm WARN lifecycle - node.js

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.

Related

Meteor setup issues on Windows

We've recently upgraded our project Meteor version to v1.8.2, however when running the following command: meteor update --all-packages, were encountering some strange errors. Here's an example of one the errors:
=> Errors while initializing project:
While loading package angular-compilers#0.3.4:
error: Command failed: C:\Windows\system32\cmd.exe /c
E:\Applications\Meteor\.meteor\packages\meteor-tool\1.10.2\mt-os.windows.x86_64\dev_bundle\bin\npm.cmd rebuild --update-binary
Cannot download "https://github.com/sass/node-sass/releases/download/v4.7.2/win32-x64-72_binding.node":
HTTP error 404 Not Found
Hint: If github.com is not accessible in your location
try setting a proxy via HTTP_PROXY, e.g.
export HTTP_PROXY=http://example.com:1234
or configure npm proxy via
Some additional information:
After checking the logs, it seems the meteor tool were using is 1.10.2. Does using the latest meteor tool for a v1.8.2 project cause issues?
1 verbose cli 'E:\\Applications\\Meteor\\.meteor\\packages\\meteor-tool\\1.10.2\\mt-os.windows.x86_64\\dev_bundle\\bin\\node.exe',
Any ideas what's wrong?
Thanks!
Can you post the full logs from meteor update?
Are you using fourseven:scss? Because it installs it’s own version of node-sass which is likely the problem.
Have a look at the version compatibility table here: https://github.com/Meteor-Community-Packages/meteor-scss
And check that the version of fourseven:scss matches a compatible meteor version.
The alternative is to remove it, update and install the atmosphere package again, that way it won’t get in the way of the updater’s dependency resolver
Note that if you are using fourseven:scss, there’s no need to have node-sass in package.json.

Azure Deployment Angular .NetCore

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

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.

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