簡體   English   中英

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 您添加到 package 的任何其他內容,您必須使用npm run才能讓 npm 識別它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM