关于ios:[email protected]需要一个[email protected]的同位体,但未安装

[email protected] requires a peer of [email protected] but none was installed

我正在尝试为react native设置。但是每当我更新文件时,它都会给出m错误

1
2
3
4
5
6
7
    enoent ENOENT: no such file or directory, open 'React Native/package.json'
npm WARN [email protected] requires a peer of [email protected] but none was installed.
npm WARN React Native No description
npm WARN React Native No repository field.
npm WARN React Native No README data
npm WARN React Native No license field.
   MacBook-Pro:React Native$ npm info react dist-tags.latest

请让我知道如何解决。


安装react应该可以修复错误

1
npm install react --save

此外,您可以尝试升级react-native安装。 react-native现在和v0.30.0一样

1
npm update react-native

在我的特定情况下,我在错误的目录中运行了npm install。我以为我在我的项目目录中,但是比我高了一个级别。这意味着已安装的软件包中缺少react(因为没有),因此出现此错误。


就我而言,我正在从事的项目需要特定版本的React。由于它比当前版本要旧,因此执行安装/更新仍会导致错误。

为了解决问题,我必须检查项目的package.json并安装依赖项定义允许的确切版本。在OP的情况下,

1
npm install [email protected]

应该通过安装react-native所需的React模块的确切版本来解决该问题。

通过执行npm list以查看是否存在任何其他未满足的对等依赖项来验证条件是否已解决。


一些对我有用的步骤:

1
2
3
4
5
6
7
1. watchman watch-del-all
2. rm -rf node_modules
3. npm install [email protected] --save
4. npm install [email protected] --save
5. npm install
6. rm -fr $TMPDIR/react-*
7. npm start -- --reset-cache