javascript - 如何修复 "Npm ERR! JSON.parse Unexpected string in JSON at position 228.."

标签 javascript

我在安装后尝试启动 NPM,但启动出错。

我在“package.json”文件中找不到语法错误 我找不到错误日志 我试过重新安装 我尝试清除缓存 都没有成功

这是我的“package.json”文件:

{
  "name": "git-test",
  "version": "1.0.0",
  "description": "test json file",
  "main": "index.js",
  "dependencies": {},
  "devDependencies": {
    "lite-server": "^2.4.0"
  },
  "scripts": {
    "start": "npm run lite"
    "test": "echo \"Error: no test specified\" && exit 1"
    "dev": "lite-server"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools.git"
  },
  "author": "Master-Hippo",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/Master-Hippo/Front-        
End_Web_UI_Frameworks_and_Tools/issues"
  },
  "homepage": "https://github.com/Master-Hippo/Front-    
End_Web_UI_Frameworks_and_Tools#readme"

错误日志如下:

npm ERR! code EJSONPARSE
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected string in JSON at position 228 while parsing 
'{
npm ERR! JSON.parse   "name": "git-test",
npm ERR! JSON.parse   "version": "1.'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.

而且,尽管消息说在特定文件夹中创建了错误日志,但该文件夹中实际上不存在错误日志。

我该如何解决这个问题?

最佳答案

尝试使用 jsonlint 验证您的 package.json

我猜你的文件可能是这样的:

{
    "name": "git-test",
    "version": "1.0.0",
    "description": "test json file",
    "main": "index.js",
    "dependencies": {},
    "devDependencies": {
        "lite-server": "^2.4.0"
    },
    "scripts": {
        "start": "npm run lite",
        "test": "echo \"Error: no test specified\" && exit 1",
        "dev": "lite-server"
    },
    "repository": {
        "type": "git",
        "url": "git+https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools.git"
    },
    "author": "Master-Hippo",
    "license": "ISC",
    "bugs": {
        "url ": "https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools/issues"
    },
    "homepage": "https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools#readme"
}

关于javascript - 如何修复 "Npm ERR! JSON.parse Unexpected string in JSON at position 228..",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56228659/

相关文章:

javascript - 恢复页面刷新时下拉选择的选项?

javascript - 从数组中删除特定元素 - javascript

javascript - 如何使用 Javascript 从字符串中提取数字?

javascript - 如何使用 ES6 导入插件? (获取引用错误 : Plugin is not defined)

javascript - 纯Javascript,没有jquery

javascript - 使用JavaScript从客户端浏览器上传到Google Cloud Storage

javascript - 有没有办法在 React 应用程序中链接非 React html 文件?

javascript - 是否需要setTimeout?

javascript - 类型错误 : Cannot read property 'username' of undefined from Form Submit

javascript - .offset() 并检查 jQuery 中的位置