实际行为
从头开始启动 React Native 项目时,我没有启动,而是出现红屏和此错误消息: Cannot Find Entry file index.ios.js in any of the project root ["/Users/neo/newProjects/F2"]
预期行为
启动一个干净的应用程序启动器
我正在尝试做什么
我正在尝试在 android 和 ios 模拟器中从头开始初始化并运行一个反应本机项目,但出现以下错误。
我尝试过的
我尝试执行以下操作:
通过文档安装
- 多次执行此处列出的安装步骤:https://facebook.github.io/react-native/docs/getting-started.html https://facebook.github.io/react-native/docs/getting-started.html
NPM安装
编辑 .profiles ( android )
- 编辑 ~.profiles 文件,设置 android home 变量..这就是现在的样子:
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" $
export ANDROID_HOME=${HOME}/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools`
npm 启动
运行 npm start 并检查端口上的活动(包管理器是否正在运行)
检查端口的活动
(忘记了如何,已验证其可用)
对某人有用的代码...
我也尝试过在终端中运行此代码
react-native bundle \
--entry-file=index.ios.js \
--platform=ios \
--dev=false \
--assets-dest=./production/ios \
--bundle-output=./production/ios/ios.jsbundle
看完这篇文章后https://github.com/facebook/react-native/issues/8664 https://github.com/facebook/react-native/issues/8664
并收到此错误消息:
ENOENT:没有这样的文件或目录,打开'./product/ios/ios.jsbundle'
我注意到这个建议
重新运行 npm install 和 rnpm link
我尝试运行 rnpm link,但得到“没有找到这样的命令”
读完这篇文章后来自打包器的 React Native 中的入口文件错误 https://stackoverflow.com/questions/37999468/entry-file-error-in-react-native-from-packager
在同一篇文章中我看到了这个:
“发现更新到 RN 0.28 后,我的应用程序由于不兼容的依赖项而出现此问题。这就是我解决此问题的方法”
rm -rf node_modules
npm cache clean
然后打开package.json,除了react-native将所有包版本更改为*
Then run
npm 更新--保存
npm 更新 --save-dev
检查 package.json 是否使用版本号更新,如果没有从 npmjs 验证并手动更新
从设备中删除应用程序并尝试再次运行
- 但我无法辨别顾问在这里做什么......以及其背后的逻辑......如果它看起来相关,有人可以对此发表评论吗?
端子输出
我在终端中得到这个:
Loading dependency graph, done.
error: bundling: Error
at DependencyGraph._getAbsolutePath
(/Users/neo/newProjects/F2/node_modules/react-native/packager/src/node-haste/index.js:272:11)
at DependencyGraph.getDependencies (/Users/neo/newProjects/F2/node_modules/react-native/packager/src/node-haste/index.js:216:26)
at Resolver.getDependencies (/Users/neo/newProjects/F2/node_modules/react-native/packager/src/Resolver/index.js:106:27)
at _resolverPromise.then.resolver (/Users/neo/newProjects/F2/node_modules/react-native/packager/src/Bundler/index.js:561:62)
at process._tickCallback (internal/process/next_tick.js:109:7)
Bundling `index.ios.js` 0.0% (0/1), failed.
Versions
节点 v7.9.0
反应本机-cli:2.0.1
反应本机:0.44.0
自制1.2.0
刚刚更新了xcode
OSX 10.11.6 (15G1004)
我注意到什么
我注意到它似乎在这个文件中查找.. [“/Users/neo/newProjects/F2”] 而在我的计算机上的某些位置,文件被组织为 Users/Neo/... (大写用户名)...我感觉这与此有关。
另外,在项目构建中它确实会抛出此警告...不知道这意味着什么...
“反应[电子邮件受保护] /cdn-cgi/l/email-protection“有未满足的同伴依赖性”[电子邮件受保护] /cdn-cgi/l/email-protection"
有什么建议或想法吗?
update
尝试将目录更改为用户文件夹并初始化
这是我在堆栈跟踪中得到的内容
2017-05-02 09:25:21.478 xcodebuild[52491:5334564] Error saving log: Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory" UserInfo={NSFilePath=/code/F4/ios/build/Logs/Build/B9E13558-CCE5-4451-AC21-7E643189BF7B.xcactivitylog, NSLocalizedDescription=No such file or directory} | User info: {
NSFilePath = "/code/F4/ios/build/Logs/Build/B9E13558-CCE5-4451-AC21-7E643189BF7B.xcactivitylog";
NSLocalizedDescription = "No such file or directory";
}
Installing build/Build/Products/Debug-iphonesimulator/F4.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/F4.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
另外,尝试安装 expo 并从那里运行......
这是终端显示的内容
Error sourcing shell startup scripts: /Users/neo/.bash_profile: line 2: rbenv: command not found
/Users/neo/.bash_profile: line 4: rbenv: command not found
/Users/neo/.bash_profile: line 5: rbenv: command not found
/Users/neo/.bash_profile: line 7: rbenv: command not found
/Users/neo/.bash_profile: line 9: rbenv: command not found
/bin/bash: shell_session_update: command not found
.
请跑npm install -g exp && exp path``
10:25:22 AM
Starting React Native packager...
10:25:31 AM
Scanning 656 folders for symlinks in /code/my-new-project/node_modules (11ms)
10:25:32 AM
Loading dependency graph.
10:25:32 AM
Running packager on port 19001.
10:25:32 AM
10:25:37 AM
Dependency graph loaded.
10:25:51 AM
Project opened! You can now use the "Send Link" or "Device" buttons to view your project.
10:36:58 AM
Couldn't start project on Android: could not install *smartsocket* listener: Address already in use
ADB server didn't ACK
* failed to start daemon *
error: cannot connect to daemon
`