【问题标题】:Missing files in .bin folder when deploying Node App to Azure App Service将节点应用程序部署到 Azure 应用程序服务时 .bin 文件夹中缺少文件
【发布时间】:2021-07-17 09:57:25
【问题描述】:

所以我试图将我的反应应用程序部署到 Azure Web 应用程序。 我使用 Github Action 构建和安装应用程序,然后将其 ZIP 部署到 Azure。 问题是,一旦我打开 WebApp 页面,它就会显示一个应用程序错误(找不到反应脚本)。
我发现一旦我将 react-scripts.cmd / ps1(从本地 /node_modules/.bin)复制到 webapp 的 node_modules/.bin 文件夹“https://{WEBAPP-NAME}.scm.azurewebsites.net “ 有用。 不幸的是,每次构建后我都必须这样做。 我该如何解决这个错误?

我已经尝试过的:

  • 更新节点和 npm
  • 删除包锁 提前致谢

最大

我的 package.json:

【问题讨论】:

    标签: node.js reactjs azure npm github-actions


    【解决方案1】:

    看起来像这个问题:npm package.json scripts not being called

    如果您想执行不是由内置npm 命令执行的脚本,请尝试运行npm run-script

    【讨论】:

    • 我该怎么做?据我所知,应用服务只是运行 npm start,我如何/在哪里可以做到这一点?
    • 如何调用脚本?
    • 本地我只是简单地运行 npm start。对于应用服务:我通过一个 Github 操作部署它,该操作执行 npm 安装、构建并将其部署到 azure 应用服务
    • 我的意思是你在哪里打电话给react-scripts
    • 在 package.json 下的脚本 ("start" : "react-scripts start") 中(如上面的屏幕截图所示)。据我所知,npm start 命令只运行在 package.json 中的 scripts 部分下的给定代码
    【解决方案2】:

    所以我发现,react-scripts 只在开发环境中工作。但 Azure 使用生产环境。因此,github 操作不仅要安装 prod node_modules (npm install),还要安装 dev 模块 (npm install --only=dev)。

    参考: https://github.com/mars/create-react-app-buildpack/issues/32#issuecomment-276081892

    【讨论】:

      猜你喜欢
      • 2014-07-23
      • 2023-03-27
      • 2016-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多