package.json 中的自定义反应脚本无法识别
Custom react script in package.json is not recognised
我在 package.json 文件的反应脚本中向 运行 添加了一个自定义命令,这样我就可以从那里 运行 一个 api 服务器
{
"name": "appfrontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1"
},
"scripts": {
"start": "react-scripts start",
"start-api": "cd .. && cd appbackend && venv/bin/flask run", # This is the command I added
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"proxy": "http://localhost:5000"
}
但 npm 无法识别此命令。似乎是什么问题?我不应该 运行 我的新脚本
npm start-api
您需要使用 npm run start-api
npm 默认只识别少数特定命令。 https://docs.npmjs.com/cli-documentation/cli。添加到包中的任何其他内容,都必须使用 npm run
才能让 npm 识别它。
我在 package.json 文件的反应脚本中向 运行 添加了一个自定义命令,这样我就可以从那里 运行 一个 api 服务器
{
"name": "appfrontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1"
},
"scripts": {
"start": "react-scripts start",
"start-api": "cd .. && cd appbackend && venv/bin/flask run", # This is the command I added
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"proxy": "http://localhost:5000"
}
但 npm 无法识别此命令。似乎是什么问题?我不应该 运行 我的新脚本
npm start-api
您需要使用 npm run start-api
npm 默认只识别少数特定命令。 https://docs.npmjs.com/cli-documentation/cli。添加到包中的任何其他内容,都必须使用 npm run
才能让 npm 识别它。