反应:看起来您在全球安装了反应



在全球安装时,似乎有一个带有反应的错误。我需要它正确执行而不看到此错误:

$ 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"
 }

在我的情况下,这个问题是因为NPM是使用Homebrew安装的。该问题的描述以及如何解决该问题。总之,所需的修复程序是卸载所有NPM全面安装的软件包,卸载节点,然后重新安装节点,然后重新安装NPM,而无需酿造。

npm list -g --depth=0 # to list all your globally installed packages
rm -rf /usr/local/lib/node_modules
brew uninstall node
brew install node --without-npm
echo prefix=~/.npm-packages >> ~/.npmrc
curl -L https://www.npmjs.com/install.sh | sh

然后,您必须重新安装使用npm install -g <package_name>全球安装的所有NPM软件包。

不幸的是,当我重新启动我的机器时,同样的问题重新解决了。我目前的工作是遵循此处的建议,即

npm install --save-dev react-native-cli

欢迎有关发生的事情的任何解释。

我遇到了这个问题,使用大约8年历史的React-native^0.17.0克隆回购。我将版本更改为最新的包装中的版本。

出于某种原因i package.json 文件中删除了所有依赖项,然后手动安装它们

yarn add react-native redux

和其余的,它对我有用,我发现问题是安装包装的版本。

相关内容

最新更新