node.js - React-native:看起来你在全局安装了 react-native

标签 node.js reactjs npm react-native npm-install

在全局安装时,react-native 似乎有一个错误。我需要它正确执行而不会看到此错误:

$ react-native run-ios
Looks like you installed react-native globally, maybe you meant react-native-cli?
To fix the issue, run:
npm uninstall -g react-native
npm install -g react-native-cli

其他论坛上发布的解决方案对我不起作用,我不明白为什么这不起作用。

package.json:

{
  "name": "react-native-svgkit",
  "version": "0.2.2",
  "main": "Svg.js",
  "description": "A <Svg /> element for react-native that renders Svg images using SVGKit",
  "author": "Brent Vatne <brentvatne@gmail.com> (https://github.com/brentvatne)",
  "peerDependencies": {
    "react": "15.1.0",
    "react-native": ">=0.4.4"
  },
  "devDependencies": {
    "react-native": ">=0.4.4",
    "react-native-cli": "^0.1.10"
  },
  "dependencies": {
    "d3": "^3.5.5",
    "jsdom-jscore": "^0.1.0",
    "react-native-svg": "^2.2.0"
  },
  "repository": {
    "type": "git",
    "url": "git@github.com:brentvatne/react-native-svgkit.git"
  },
  "scripts": {
    "start": "node /usr/local/lib/node_modules/react-native/local-cli/cli.js start"
  }
}

最佳答案

在 package.json 中使用它

"scripts": {
   "android": "node node_modules/react-native/local-cli/cli.js run-android"
}

代替

"scripts": {
    "android": "react-native run-android"
 }

关于node.js - React-native:看起来你在全局安装了 react-native,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37949641/

相关文章:

npm - 如何创建和运行自己的peerjs服务器?

javascript - 401 状态处理,带访问和刷新 Token React, Node

javascript - 在同一个请求中进行两个方法调用

javascript - Mongoose 不保存对文档的更改

javascript - Passport JS 和 Auth0 之间有什么关系?

reactjs - Graphql:Typescript + Jest + Relay + Jest 似乎无法集成在一起

javascript - 数字验证中的逻辑错误以及 React Js 中的百分比符号

reactjs - 一个组件中的多个表单无法识别表单和初始值属性(redux-form v7.0.4)

node.js - NPM 安装,使用构建脚本移动文件

angular - 如何在没有 npm 和 Node.js 的情况下使用 AngularJS 2?