我正在尝试将我的 React 网站托管到 GitHub,但是当我尝试使用时:
npm install --save gh-pages
我收到以下错误:
Failed to parse json
npm ERR! JSON.parse Unexpected string in JSON at position 608 while parsing '{
npm ERR! JSON.parse "name": "myportfoliosite",
npm ERR! JSON.parse "versio'
存储库位于:https://github.com/InquisitiveDev2016/React-Developer-Portfolio2
这是 package.json 文件:
{
"name": "myportfoliosite",
"version": "0.1.0",
"private": true,
"homepage": "https://github.com/InquisitiveDev2016/React-Developer-Portfolio2",
"dependencies": {
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-mdl": "^1.11.0",
"react-router-dom": "^5.0.1",
"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"
]
}
}
我正在尝试按照 GitHub 页面文件夹下的说明进行操作,网址为: https://facebook.github.io/create-react-app/docs/deployment
但是我卡住了,有人可以检查文件有什么问题吗?
最佳答案
此 package.json 不是有效的 JSON 您可以尝试使用在线工具修复 JSON 结构并验证 JSON
以下 JSON 应该适合您:
{
"name": "myportfoliosite",
"version": "0.1.0",
"private": true,
"homepage": "https://github.com/InquisitiveDev2016/React-Developer-Portfolio2",
"dependencies": {
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-mdl": "^1.11.0",
"react-router-dom": "^5.0.1",
"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"
]
}
}
关于javascript - 解析时 JSON 中位置 608 处的意外字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56813744/