【问题标题】:Deploying create-react-app with NodeJs Backend on Azure在 Azure 上使用 NodeJs 后端部署 create-react-app
【发布时间】:2021-08-07 19:53:07
【问题描述】:

我用 npm create-react-app 制作了一个使用 NodeJS 后端的 React 应用程序。我正在尝试通过 Visual Studio Code 扩展在 Azure 上进行部署。

我没有在本地构建,而是将脚本放在 package.json(根文件夹)中的脚本对象中

 "build": "cd client && npm install && npm run build"

我的 server.js 像这样解析到 react 应用的路由:

app.use(express.static("client/build"));
app.get("*", (req, res) => {
  res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));
});

在我配置应用服务、资源计划等并部署到应用服务中的应用后,我得到

Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 12.x
Found bindings for the following environments:
Windows 64-bit with Node.js 12.x

我在应用服务中的 Files 文件夹是空的(只有 hostingstart.html)

我尝试删除 node-sass 并重新安装它,我尝试重建它但没有任何帮助。

【问题讨论】:

    标签: node.js reactjs azure node-sass


    【解决方案1】:

    你可以先查看你的node-sass版本:npm ls node-sass

    看看Node-sass release URL

    我认为您已经通过删除和重新安装包完成了正确的操作,请确保您在项目的 根路径 中运行这些命令。

        npm rebuild node-sass
        npm update
    
        npm uninstall node-sass
        npm install node-sass
    

    别忘了重启你的项目。

    【讨论】:

      猜你喜欢
      • 2019-09-07
      • 2023-03-02
      • 2017-06-06
      • 2020-08-18
      • 2019-12-24
      • 1970-01-01
      • 2019-07-11
      • 2020-01-27
      • 2018-06-19
      相关资源
      最近更新 更多