在 Azure 上使用 NodeJs 后端部署 create-react-app

问题描述 投票:0回答:2

我使用 npm create-react-app 制作了一个 React 应用程序,它使用 NodeJS 后端。我正在尝试通过 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

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

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

node.js reactjs azure node-sass
2个回答
0
投票

你可以先检查一下你的node-sass版本:

npm ls node-sass

查看Node-sass 发布 URL

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

    npm rebuild node-sass
    npm update

    npm uninstall node-sass
    npm install node-sass

不要忘记重新启动您的项目。


0
投票

您是否尝试过将其部署在 Linux 服务应用程序计划上?从错误来看,您似乎是为 Linux 而不是 Windows 构建的。

© www.soinside.com 2019 - 2024. All rights reserved.