0

我正在使用React Native 入门说明。我正在使用带有 macOS Sierra 10.12.6 的 2010 MacBook Pro。计算机有 Node.js v8.4.0。

我是 React Native 的新手,也是 React 和 Node 的新手,所以我可能会遗漏一些基本的东西。我确实让 React 在同一台计算机上工作。我按照上面页面上的说明进行操作,希望看到npm start命令启动开发服务器并在终端上打印二维码,如说明所述。

第一次尝试入门时,我收到了一些错误消息,您可以在下面找到这些消息。根据这些消息,我安装了 watchman 并npm start再次尝试。那个时候,该应用程序似乎启动了一个服务器。我没有看到二维码,但几秒钟后出现了一些错误消息,然后什么也没有。

这是 shell 会话的样子。有些部分很长(数百行),我把它们排除在外。我已经包含了我发现的所有错误和警告。

bash-3.2$ create-react-native-app AwesomeProject # verbatim from the getting-started page
Creating a new React Native app in /Users/dvincent/Desktop/react-native-test/AwesomeProject.

Using package manager as npm with npm interface.
Installing packages. This might take a couple minutes.
Installing react-native-scripts...

[?25hAwesomeProject@0.1.0 /Users/dvincent/Desktop/react-native-test/AwesomeProject
`-- react-native-scripts@1.3.0 
  +-- @expo/bunyan@1.8.10 
  | +-- moment@2.18.1 

在这里,我省略了数百行似乎并不重要的行。这些看起来确实很重要:

    +-- uuid@3.1.0  deduped
    +-- xmldom@0.1.27 
    `-- yesno@0.0.1 

npm WARN react-redux@5.0.6 requires a peer of react@^0.14.0 || ^15.0.0-0 || ^16.0.0-0 but none was installed.
Installing dependencies using npm...

[?25hnpm WARN deprecated connect@2.30.2: connect 2.x series is deprecated
[?25h
> fsevents@1.1.2 install /Users/dvincent/Desktop/react-native-test/AwesomeProject/node_modules/fsevents
> node install

[fsevents] Success: "/Users/dvincent/Desktop/react-native-test/AwesomeProject/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
[?25hAwesomeProject@0.1.0 /Users/dvincent/Desktop/react-native-test/AwesomeProject
+-- expo@20.1.1 
| +-- @expo/vector-icons@5.2.0 
| | `-- react-native-vector-icons@4.1.1 
| |   `-- yargs@6.6.0  deduped
| +-- babel-preset-expo@3.0.0 
| | +-- babel-plugin-module-resolver@2.7.1 
| | | +-- find-babel-config@1.1.0 

在到达一些警告并看到成功之前,我在这里省略了更多行!消息如预期。

|   +-- y18n@3.2.1 
|   `-- yargs-parser@4.2.1 
|     `-- camelcase@3.0.0  deduped
`-- react-test-renderer@16.0.0-alpha.12 

npm WARN react-native-gesture-handler@1.0.0-alpha.17 requires a peer of react@>= 16.0.0 but none was installed.
npm WARN react-native-branch@2.0.0-beta.3 requires a peer of react@>=15.4.0 but none was installed.
npm WARN lottie-react-native@1.1.1 requires a peer of react@>=15.3.1 but none was installed.


Success! Created AwesomeProject at /Users/dvincent/Desktop/react-native-test/AwesomeProject
Inside that directory, you can run several commands:

  npm start
    Starts the development server so you can open your app in the Expo
    app on your phone.

并以以下结尾。

We suggest that you begin by typing:

  cd AwesomeProject
  npm start

Happy hacking!

所以我继续,像这样:

bash-3.2$ cd AwesomeProject/
bash-3.2$ npm start

> AwesomeProject@0.1.0 start /Users/dvincent/Desktop/react-native-test/AwesomeProject
> react-native-scripts start

1:59:58 PM: Unable to start server
See https://git.io/v5vcn for more information, either install watchman or run the following snippet:
  sudo sysctl -w kern.maxfiles=5242880
  sudo sysctl -w kern.maxfilesperproc=524288

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! AwesomeProject@0.1.0 start: `react-native-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the AwesomeProject@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/dvincent/.npm/_logs/2017-09-01T03_59_58_661Z-debug.log

我暂时搁置了内核建议,而是安装了watchman。

bash-3.2$ npm install watchman
[?25hAwesomeProject@0.1.0 /Users/dvincent/Desktop/react-native-test/AwesomeProject
`-- watchman@0.1.8 
  +-- cli@1.0.1 
  | +-- exit@0.1.2 
  | `-- glob@7.1.2 
  `-- eco@1.1.0-rc-3 
    +-- coffee-script@1.12.7 
    `-- strscan@1.0.1 

npm WARN lottie-react-native@1.1.1 requires a peer of react@>=15.3.1 but none was installed.
npm WARN react-native-branch@2.0.0-beta.3 requires a peer of react@>=15.4.0 but none was installed.
npm WARN react-native-gesture-handler@1.0.0-alpha.17 requires a peer of react@>= 16.0.0 but none was installed.

然后我尝试再次启动服务器。

bash-3.2$ npm start

> AwesomeProject@0.1.0 start /Users/dvincent/Desktop/react-native-test/AwesomeProject
> react-native-scripts start

2:29:06 PM: Starting packager...
***ERROR STARTING PACKAGER***
Starting React Native packager...
Scanning 767 folders for symlinks in /Users/dvincent/Desktop/react-native-test/AwesomeProject/node_modules (21ms)
Loading dependency graph.
Running packager on port 19001.


2017-09-01 14:29 node[22151] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
***ERROR STARTING PACKAGER***

2017-09-01 14:29 node[22151] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
***ERROR STARTING PACKAGER***

2017-09-01 14:29 node[22151] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)


在这一点上,我停止了等待,并捕获了 shell 记录以开始讨论这个问题。我在写这篇文章时让它继续运行了 40 多分钟,没有进一步的输出。

4

1 回答 1

1

当您使用 npm 安装 watchman 时,这看起来像是一个已知问题。它可以通过删除使用 npm 安装的 watchman 并使用 homebrew 安装来修复。

# Remove any existing binaries
rm -rf /usr/local/var/run/watchman/
# Remove any npm globally installed instances
npm uninstall watchman
# Nuke the last brew installed version
brew uninstall watchman
# Brew install and build latest
brew install watchman

有关更多详细信息,请参阅此问题

于 2017-09-01T08:45:18.950 回答