NativeBase设置/安装错误

时间:2018-07-04 06:16:50

标签: node.js react-native npm visual-studio-code native-base

我正在尝试使用official document在我的React-Native项目中设置/安装Native-Base。但是每次都会出错。

命令: npm install native-base --save

错误:

  

npm错误!解析“ ... yish /-/ is-arrayish-0”附近时,JSON输入意外结束。

     

npm错误!可以在以下位置找到此运行的完整日志:

     

npm错误! /home/abhijitsrivastava/.npm/_logs/2018-07-04T06_03_24_057Z-debug.log

系统规格:

node --version
v8.1.0

npm --version
6.0.0

react-native --version
react-native-cli: 2.0.1
react-native: 0.55.4

Machine: Ubuntu 16.04LTS

IDE: Visual Studio Code Version 1.23.0

根据compatibility矩阵,一切正常。我不知道该如何解决。

更新:

这是我的package.json文件。

{
  "name": "xyz",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.3.1",
    "react-native": "^0.55.4",
    "react-navigation": "^2.3.1",
    "redux": "^4.0.0"
  },
  "devDependencies": {
    "babel-jest": "23.0.1",
    "babel-preset-react-native": "4.0.0",
    "jest": "23.1.0",
    "react-test-renderer": "16.3.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

2 个答案:

答案 0 :(得分:0)

我在最近的论坛帖子中注意到,他们建议使用yarn代替npm来安装依赖项和创建react native应用。

纱线: https://yarnpkg.com/en/docs/install#windows-stable

安装纱线后,尝试发出以下命令,

yarn add native-base --save

希望这会有所帮助!

答案 1 :(得分:0)

在同一行上尝试过,没有问题

enter image description here

    {
    "name": "NativebaseKitchenSink",
    "version": "2.5.2",
    "private": true,
    "devDependencies": {
        "babel-eslint": "7.2.3",
        "eslint": "4.4.1",
        "eslint-plugin-flowtype": "2.35.0",
        "eslint-plugin-import": "2.7.0",
        "eslint-plugin-jsx-a11y": "6.0.2",
        "eslint-plugin-prettier": "2.1.2",
        "eslint-plugin-react": "7.1.0",
        "eslint-plugin-react-native": "3.0.1",
        "flow-bin": "0.52.0",
        "flow-typed": "2.1.5",
        "husky": "0.14.3",
        "jest": "20.0.4",
        "jest-expo": "25.0.0",
        "prettier": "1.5.3",
        "react-test-renderer": "16.3.1"
    },
    "scripts": {
        "start": "react-native start",
        "android": "react-native run-android",
        "ios": "react-native run-ios",
        "test": "node node_modules/jest/bin/jest.js --watch"
    },
    "jest": {
        "preset": "react-native"
    },
    "dependencies": {
        "color": "1.0.3",
        "lodash": "4.13.1",
        "moment": "2.13.0",
        "native-base": "^2.6.1",
        "react": "16.3.1",
        "react-native": "0.55.4",
        "react-navigation": "1.5.0"
    }
    }