意外使用保留字'import React-native

时间:2018-05-31 05:24:57

标签: react-native babeljs

enter image description here 我的bable.src文件代码在这里

 {
  "presets": ["es2015"]
}

Package.json文件代码在这里

{
        "name": "Zoylo",
        "version": "0.0.1",
        "private": true,
        "scripts": {
            "start": "node node_modules/react-native/local-cli/cli.js start",
            "postinstall": "rm ./node_modules/react-native/local-cli/core/__fixtures__/files/package.json",
            "test": "jest"
        },
        "dependencies": {
            "@ptomasroos/react-native-multi-slider": "0.0.11",
            "babel-core": "^6.26.0",
            "babel-loader": "^7.1.2",
            "jwt-node-decoder": "0.0.4",
            "npm": "^5.3.0",
            "prop-types": "^15.6.1",
            "react": "^16.2.0",
            "react-dom": "^16.3.2",
            "react-native": "^0.52.0",
        },
        "devDependencies": {
            "babel-eslint": "^8.0.3",
            "babel-jest": "20.0.3",
            "babel-plugin-transform-export-extensions": "^6.22.0",
            "babel-preset-env": "^1.6.1",
            "babel-preset-es2015": "^6.24.1",
            "babel-preset-react": "^6.24.1",
            "babel-preset-react-native": "^4.0.0",
            "babel-preset-stage-2": "^6.24.1",
            "jest": "20.0.4",
            "react-test-renderer": "16.0.0-alpha.12"
        },

    }

我认为这是一个很大的问题。它在1天前和npm安装后工作正常我正面临这个问题。

1 个答案:

答案 0 :(得分:4)

我得到了答案。我的.babelrc文件有问题,现在这是我的新.babelrc文件

{ "env": { "test": { "presets": [ "env", "react", "es2015", "stage-2" ], "plugins": [ "transform-export-extensions" ], "only": [ "./**/*.js", "node_modules/jest-runtime" ] } }, "presets": [ "react-native" ] }

,并且还需要运行此命令。

watchman watch-del-all && rm -rf node_modules/ && npm cache clean --force && npm install && npm start -- --reset-cache