【问题标题】:Accidentally deleted node_modules folder意外删除了 node_modules 文件夹
【发布时间】:2017-12-17 09:16:26
【问题描述】:

我不小心删除了我的node_modules 文件夹。我知道找回它的方法就是运行npm install,但这在我的情况下不起作用。这说明我的JSON 文件有问题。我在Terminal 中收到此错误。

这是我的Package.js 文件:

{
  "name": "App",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "aws-sdk": "git://github.com/aws/aws-sdk-js.git#react-native",
    "react": "^16.0.0-alpha.12",
    "react-native": "^0.45.1",
    "react-native-aws-signature": "0.0.9",
    "react-native-dropdown-menu": "^1.1.0",
    "react-native-dynamodb": "0.0.5",
    "react-redux": "^5.0.5",
    "redux": "^3.7.1"
  },
  "devDependencies": {
    "babel-jest": "20.0.3",
    "babel-preset-react-native": "2.0.0",
    "jest": "20.0.4",
    "react-test-renderer": "16.0.0-alpha.12"
  },
  "jest": {
    "preset": "react-native"
  },
}

错误:

Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR! 
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse

npm ERR! Please include the following file with any support request:

【问题讨论】:

    标签: javascript reactjs react-native terminal


    【解决方案1】:

    第27行有错误,足够,这里是一个有效的json

    {
        "name": "TorusTApp",
        "version": "0.0.1",
        "private": true,
        "scripts": {
            "start": "node node_modules/react-native/local-cli/cli.js start",
            "test": "jest"
        },
        "dependencies": {
            "aws-sdk": "git://github.com/aws/aws-sdk-js.git#react-native",
            "react": "^16.0.0-alpha.12",
            "react-native": "^0.45.1",
            "react-native-aws-signature": "0.0.9",
            "react-native-dropdown-menu": "^1.1.0",
            "react-native-dynamodb": "0.0.5",
            "react-redux": "^5.0.5",
            "redux": "^3.7.1"
        },
        "devDependencies": {
            "babel-jest": "20.0.3",
            "babel-preset-react-native": "2.0.0",
            "jest": "20.0.4",
            "react-test-renderer": "16.0.0-alpha.12"
        },
        "jest": {
            "preset": "react-native"
        }
    }
    

    【讨论】:

      【解决方案2】:

      我相信这是因为您的 package.js 文件的倒数第二行多了一个逗号。

      【讨论】:

        【解决方案3】:

        通过在线 json 验证器运行此 json。例如https://jsonlint.com/

        之前的答案是正确的,但这应该对您将来有所帮助。

        【讨论】:

          猜你喜欢
          • 2015-07-07
          • 2022-09-28
          • 2023-02-01
          • 2017-05-24
          • 2021-03-21
          • 2011-12-11
          • 2014-05-04
          • 2017-01-30
          • 1970-01-01
          相关资源
          最近更新 更多