【发布时间】:2021-06-21 02:39:23
【问题描述】:
我正在尝试将客户端和服务器代码从单个 git 存储库部署到 heroku。当我运行“npm run build”时,我得到了这个:
但是没有创建文件夹,所以我无法部署应用程序。
这是我的 package.json 脚本
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
这是我的代码,让我们的 Express 服务器知道为我们的项目提供服务:
(process.env.NODE_ENV === "production") {
app.use(express.static(__dirname + "/public", "../../client/build"));
app.get("*", (req, res) =>
res.sendFile(
path.join(__dirname, "../../client/build", "/public/index.html")
)
);
}
【问题讨论】:
-
上面写着
The ..\server\public directoy is ready to be deployed.将你的快递服务器调整到那个路径。