【问题标题】:How i can handle an error in package.json?我如何处理 package.json 中的错误?
【发布时间】:2020-08-22 11:48:51
【问题描述】:

我的 package.json 有问题。这是一个克隆项目,我修改了逗号,它们没问题。所以我不知道错误在哪里。 终端是这样说的:

npm ERR! code EJSONPARSE
npm ERR! file C:\Users\Emege\package.json
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected end of JSON input while parsing near ''
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Emege\AppData\Roaming\npm-cache\_logs\2020-08-22T03_04_56_980Z-debug.log.

我读了这篇文章,但它对我没有帮助https://dev.to/redslug/7-solutions-to-ejsonparse-or-unexpected-token-npm-install-error-20nh

And this is the package.json


  {
      "name": "tvpassport",
      "version": "1.0.0",
      "description": "Autentificacion de usuarios",
      "main": "server.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "Jean Mariños",
      "license": "ISC",
      "dependencies": {
        "body-parser": "^1.14.1",
        "connect-flash": "^0.1.1",
        "connect-redis": "^3.0.1",
        "express": "^4.13.3",
        "express-session": "^1.12.1",
        "mongoose": "^4.2.5",
        "passport": "^0.3.2",
        "passport-facebook": "^2.0.0",
        "passport-local": "^1.0.0",
        "swig": "^1.4.2"
      }
    }

   

【问题讨论】:

  • 除了逗号,引号有时也会带来问题。你确定报价没有错误吗?比如,在从 MS word 复制时,会复制不同的 ASCII 字符

标签: node.js npm package.json


【解决方案1】:

你的 package.json 文件中只需要这个:

{
      "name": "tvpassport",
      "version": "1.0.0",
      "description": "Autentificacion de usuarios",
      "main": "server.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "Jean Mariños",
      "license": "ISC",
      "dependencies": {
        "body-parser": "^1.14.1",
        "connect-flash": "^0.1.1",
        "connect-redis": "^3.0.1",
        "express": "^4.13.3",
        "express-session": "^1.12.1",
        "mongoose": "^4.2.5",
        "passport": "^0.3.2",
        "passport-facebook": "^2.0.0",
        "passport-local": "^1.0.0",
        "swig": "^1.4.2"
      }
    }

删除这个:````````

【讨论】:

  • 我认为这实际上不在 OP 的 package.json 中。相反,这可能只是格式错误。
  • 你好,我只是一个学生,那可能是什么样的格式错误?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-29
相关资源
最近更新 更多