我正在 Azure 上运行 Node Web 应用程序。
我使用“本地 git”方法部署应用程序。
每次我对源代码进行更改、提交并部署时git push azure master
,网站上的代码已按预期更新。
但我最近的一项更改包括向我的package.json
文件。现在,当我部署时,我的文件已更新,但 azure 似乎没有重新运行npm install
,并且未安装新模块。这意味着应用程序不会启动:当我的代码调用时require('missingModuleName')
它遇到致命错误并停止。
上次遇到此问题时,我从 Azure 中删除了该应用程序,然后从头开始创建了一个新应用程序。但我希望有一个更简单的解决方案。
我明白了(在https://github.com/projectkudu/kudu/wiki/Deployment https://github.com/projectkudu/kudu/wiki/Deployment)在部署时“对于 Node 站点,Kudu 在 wwwroot 文件夹中运行‘npm install’”。我不确定标准的“本地 git”部署方法是否调用 Kudu 部署过程。我是否需要创建一个部署挂钩(如中所述https://github.com/projectkudu/kudu/wiki/Deployment-hooks https://github.com/projectkudu/kudu/wiki/Deployment-hooks)?
安装日志显示:
2017-07-29T07:59:51 Updating branch 'master'.
2017-07-29T07:59:52 Updating submodules.
2017-07-29T07:59:52 Preparing deployment for commit id '556a34aab5'.
2017-07-29T07:59:52 Running custom deployment command...
2017-07-29T07:59:52 Running deployment command...
2017-07-29T07:59:52 Command: deploy.cmd
2017-07-29T07:59:53 Handling node.js deployment.
2017-07-29T07:59:53 KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot'
2017-07-29T07:59:53 Copying file: 'package.json'
2017-07-29T07:59:53 Looking for app.js/server.js under site root.
2017-07-29T07:59:53 Using start-up script server.js
2017-07-29T07:59:55 Node.js versions available on the platform are: 0.6.20, 0.8.2, 0.8.19, 0.8.26, 0.8.27, 0.8.28, 0.10.5, 0.10.18, 0.10.21, 0.10.24, 0.10.26, 0.10.28, 0.10.29, 0.10.31, 0.10.32, 0.10.40, 0.12.0, 0.12.2, 0.12.3, 0.12.6, 4.0.0, 4.1.0, 4.1.2, 4.2.1, 4.2.2, 4.2.3, 4.2.4, 4.3.0, 4.3.2, 4.4.0, 4.4.1, 4.4.6, 4.4.7, 4.5.0, 4.6.0, 4.6.1, 4.8.4, 5.0.0, 5.1.1, 5.3.0, 5.4.0, 5.5.0, 5.6.0, 5.7.0, 5.7.1, 5.8.0, 5.9.1, 6.0.0, 6.1.0, 6.2.2, 6.3.0, 6.5.0, 6.6.0, 6.7.0, 6.9.0, 6.9.1, 6.9.2, 6.9.4, 6.9.5, 6.10.0, 6.11.1, 7.0.0, 7.1.0, 7.2.0, 7.3.0, 7.4.0, 7.5.0, 7.6.0, 7.7.4, 7.10.0, 7.10.1, 8.0.0, 8.1.4.
2017-07-29T07:59:55 Selected node.js version 8.1.4. Use package.json file to choose a different version.
2017-07-29T07:59:55 Selected npm version 5.0.3
2017-07-29T07:59:56 Updating iisnode.yml at D:\home\site\wwwroot\iisnode.yml
2017-07-29T07:59:56 npm WARN lifecycle The node binary used for scripts is D:\Program Files (x86)\nodejs\0.10.28\node.exe but npm is using D:\Program Files (x86)\nodejs\8.1.4\node.exe itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
2017-07-29T08:00:03 npm WARN [email protected] /cdn-cgi/l/email-protection No repository field.
2017-07-29T08:00:03 up to date in 7.206s
2017-07-29T08:00:03 npm WARN passport[email protected] /cdn-cgi/l/email-protection No license field.
2017-07-29T08:00:03
2017-07-29T08:00:03 Finished successfully.
2017-07-29T08:00:03 Running post deployment command(s)...
2017-07-29T08:00:03 Deployment successful.