[英]How can I change the directory React looks for the production build?
我使用npm build
創建了我的前端構建並將其復制到后端文件夾。 它的路徑是“后端/構建”。 我在后端目錄中運行npm start
,但是當我導航到 localhost:3001/ 並且所有 REST 端點都顯示 404 時,沒有任何顯示。
我也收到錯誤:
“ENOENT:沒有這樣的文件或目錄,stat '/home/uradora/mielentilatutkimus-thl/backend/builds/thl/build/index.html'”
所以它正在尋找:
backend/builds/thl/build/index.html
當構建文件夾的實際路徑是:
backend/build/index.html
我如何更改它正在尋找的路徑?
如果您使用的是 Create React App,則可以使用 BUILD_PATH 修改BUILD_PATH
:
"scripts": {
"build": "BUILD_PATH='./backend/build' react-scripts build",
}
首先,您可以將路徑添加到腳本中:
"scripts": {
"start": "npm start --prefix path/to/your/app",
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.