'BUILD_PATH' 未被识别为内部或外部命令
'BUILD_PATH' is not recognized as an internal or external command
我想 运行 后端服务器和前端服务器在同一台服务器上。所以我构建了前端并提供了构建路径,但这不起作用。
这是我的 npm 脚本文件。
{
"name": "nasa-fe",
"version": "1.0.0",
"private": true,
"dependencies": {
"arwes": "^1.0.0-alpha.5",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-router-dom": "^5.2.0",
"react-scripts": "^4.0.3"
},
"scripts": {
"start": "react-scripts start",
"build": "BUILD_PATH=../server/public react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
当我 运行 构建命令时,它显示 'BUILD_PATH' 未被识别为内部或外部命令。我该如何解决这个问题。
BUILD_PATH是一个环境变量,就像PORT一样。在 Windows 上,默认 shell,我们设置 BUILD_PATH 变量的方式是:
设置BUILD_PATH=../server/public&& react-scripts构建
这是我更新的脚本文件。
{
"name": "nasa-fe",
"version": "1.0.0",
"private": true,
"dependencies": {
"arwes": "^1.0.0-alpha.5",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-router-dom": "^5.2.0",
"react-scripts": "^4.0.3"
},
"scripts": {
"start": "react-scripts start",
"build": "set BUILD_PATH=../server/public&& react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
我想 运行 后端服务器和前端服务器在同一台服务器上。所以我构建了前端并提供了构建路径,但这不起作用。
这是我的 npm 脚本文件。
{
"name": "nasa-fe",
"version": "1.0.0",
"private": true,
"dependencies": {
"arwes": "^1.0.0-alpha.5",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-router-dom": "^5.2.0",
"react-scripts": "^4.0.3"
},
"scripts": {
"start": "react-scripts start",
"build": "BUILD_PATH=../server/public react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
当我 运行 构建命令时,它显示 'BUILD_PATH' 未被识别为内部或外部命令。我该如何解决这个问题。
BUILD_PATH是一个环境变量,就像PORT一样。在 Windows 上,默认 shell,我们设置 BUILD_PATH 变量的方式是:
设置BUILD_PATH=../server/public&& react-scripts构建
这是我更新的脚本文件。
{
"name": "nasa-fe",
"version": "1.0.0",
"private": true,
"dependencies": {
"arwes": "^1.0.0-alpha.5",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-router-dom": "^5.2.0",
"react-scripts": "^4.0.3"
},
"scripts": {
"start": "react-scripts start",
"build": "set BUILD_PATH=../server/public&& react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}