ReactJs部署到Github页面Ejsonparse错误

时间:2019-06-03 06:48:02

标签: json reactjs github-pages

每当我添加

,尝试将{@ 3}}部署到gh-pages之后,将我的reactJs部署到github页面中
"predeploy": "npm run build",
"deploy": "gh-pages -d build",

进入我的package.json,我无法运行npm startnpm run deploy  它会给我以下错误

也尝试过

npm cache clean --force
[rogerhfcheng@rogerlinux Cubing-Timer]$ npm run deploy
npm ERR! file /home/rogerhfcheng/Cubing-Timer/package.json
npm ERR! code EJSONPARSE
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected token } in JSON at position 505 while parsing near '...t-scripts eject",
npm ERR! JSON.parse   },
npm ERR! JSON.parse   "eslintConfig":...'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.

我的package.json文件

{
  "name": "my-app",
  "homepage": "https://xxx.github.io/xxx",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "gh-pages": "^2.0.1",
    "pretty-ms": "^5.0.0",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-scripts": "3.0.1"
  },
  "scripts": {
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build",
    "start": "react-scripts start",
    "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"
    ]
  }
}

1 个答案:

答案 0 :(得分:0)

弹出脚本后出现逗号,该逗号不应该存在

应该是

    "eject": "react-scripts eject"

代替

    "eject": "react-scripts eject",

在JSON中,不应在对象中最后一个键/值对之后加逗号。您可以使用扩展名来检查并漂亮地打印JSON。也有在线选项,例如JSON validator