Azure App Service node deployment with patch-package module

238 Views Asked by At

I am trying to run patch-package during a Node app deployment on Azure App Services (deployed with continuous integration from BitBucket). The patch-package script works fine locally (on Mac), but fails on Azure (Windows). The patch-package module is installed in node_modules but the post-install script fails with the following error:

Command: "D:\home\site\deployments\tools\deploy.cmd" Handling node.js deployment. Creating app_offline.htm KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot' Deleting app_offline.htm Looking for app.js/server.js under site root. Using start-up script app.js Generated web.config. The package.json file does not specify node.js engine version constraints. The node.js application will run with the default node.js version 14.16.0. Selected npm version 6.14.11

[email protected] postinstall D:\home\site\wwwroot patch-package

'patch-package' is not recognized as an internal or external command, operable program or batch file. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] postinstall: patch-package npm ERR! Exit status 1

And here is my (simplified) package.json file:

{
  "name": "my-app",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "private": true,
  "dependencies": {
    ...
    "patch-package": "^6.4.4",
    ...
  },
  "scripts": {
    "postinstall": "patch-package"
  }
}

I get the same error when I try and manually run npm i in Kudu command line.

2

There are 2 best solutions below

0
On BEST ANSWER

In case anyone else has this issue, here is what solved it for me:

-stopped the web app -deleted the node_modules folder -ran a new deploy from git repo (which reinstalled all modules)

Everything back to normal.

0
On

In case someone else comes across this with the same issue I had...

I had added patch-package in devDependencies, but Azure is running npm i --production so patch-package never got installed.

Changing patch-package to be in dependencies fixed it for me.