简体   繁体   English

Azure Web App 无法安装 NodeJS mysql 依赖项

[英]Azure Web App unable to install NodeJS mysql dependency

I recently created a web app on Azure, I am able to run it well, however I noticed that if I add the following line我最近在 Azure 上创建了一个 Web 应用程序,我能够很好地运行它,但是我注意到如果我添加以下行

const mysql = require('mysql');

the app will crash as it is not able to find the mysql module.该应用程序将崩溃,因为它无法找到 mysql 模块。 When I test the app locally on my machine I have no such problem, it only occurs when the app is deployed to Azure.当我在我的机器上本地测试应用程序时,我没有这样的问题,它只在应用程序部署到 Azure 时发生。 Notice that the Azure app works well with other dependencies, but it fails in installing mysql.请注意,Azure 应用程序可以很好地与其他依赖项配合使用,但无法安装 mysql。

What am I doing wrong?我究竟做错了什么? Any hint is more than welcomed.任何提示都非常受欢迎。 Thanks in advance!提前致谢!

After reproducing from our end we noticed that mysql is not visible in the node modules.从我们这边复制后,我们注意到 mysql 在节点模块中不可见。 In general, npm install works locally.一般来说, npm install在本地工作。 To make it work even after deployment ensure mysql module is being installed in ./node_modules of the application.为了使其即使在部署后也能正常工作,请确保将mysql模块安装在应用程序的 ./node_modules 中。

You can navigate to Kudu of your Web app and use npm install mysql .您可以导航到 Web 应用程序的 Kudu 并使用npm install mysql Even after doing that if you still cant find the module in the nodemodules, then just drag and drop the module from your local machine.即使这样做了,如果您仍然无法在 nodemodules 中找到该模块,那么只需从本地计算机拖放该模块即可。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM