我正在使用React Native Getting Started instructions。我正在使用MacOS Sierra 10.12.6的2010 MacBook Pro。該計算機具有Node.js v8.4.0。如何解決React Native入門中的掛起問題?
我是React Native新手,也是React和Node,所以我可能會缺少一些基本的東西。我確實有React在同一臺計算機上工作。按照上述頁面中的說明,希望看到npm start
命令啓動一個開發服務器並在終端上打印QR碼,如說明所述。
我第一次嘗試入門時,收到了一些錯誤消息,您可以在下面找到它。基於這些消息,我安裝了看守,並再次嘗試npm start
。那一次,這款應用似乎啓動了一臺服務器。我沒有看到QR碼,但幾秒鐘後出現了一些錯誤消息,然後什麼也沒有。
以下是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...
[[email protected] /Users/dvincent/Desktop/react-native-test/AwesomeProject
`-- [email protected]
+-- @expo/[email protected]
| +-- [email protected]
在這裏,我忽略了幾百條看似不重要的線條。這些看起來很重要:
+-- [email protected] deduped
+-- [email protected]
`-- [email protected]
npm WARN [email protected] requires a peer of [email protected]^0.14.0 || ^15.0.0-0 || ^16.0.0-0 but none was installed.
Installing dependencies using npm...
[?25hnpm WARN deprecated [email protected]: connect 2.x series is deprecated
[?25h
> [email protected] 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
[[email protected] /Users/dvincent/Desktop/react-native-test/AwesomeProject
+-- [email protected]
| +-- @expo/[email protected]
| | `-- [email protected]
| | `-- [email protected] deduped
| +-- [email protected]
| | +-- [email protected]
| | | +-- [email protected]
這裏我省略了更多的行,在達到一些警告並看到成功之前!消息如預期。
| +-- [email protected]
| `-- [email protected]
| `-- [email protected] deduped
`-- [email protected]
npm WARN [email protected] requires a peer of [email protected]>= 16.0.0 but none was installed.
npm WARN [email protected] requires a peer of [email protected]>=15.4.0 but none was installed.
npm WARN [email protected] requires a peer of [email protected]>=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
> [email protected] 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! [email protected] start: `react-native-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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
我拋開暫時,而是安裝守望內核建議。
bash-3.2$ npm install watchman
[[email protected] /Users/dvincent/Desktop/react-native-test/AwesomeProject
`-- [email protected]
+-- [email protected]
| +-- [email protected]
| `-- [email protected]
`-- [email protected]
+-- [email protected]
`-- [email protected]
npm WARN [email protected] requires a peer of [email protected]>=15.3.1 but none was installed.
npm WARN [email protected] requires a peer of [email protected]>=15.4.0 but none was installed.
npm WARN [email protected] requires a peer of [email protected]>= 16.0.0 but none was installed.
然後我試着再次啓動服務器。
bash-3.2$ npm start
> [email protected] 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)
在這一點上我停下來等待 和拍攝的外殼成績單,開始在這個問題上。我寫這篇文章的時間超過40分鐘,沒有進一步的輸出。