我是React Native的新手。我在世博会XDE中创建了一个新的空白项目,当我尝试在我的Android设备上运行它时,每次它在启动画面后崩溃时。这只是一个简单的空白应用程序。
没有日志或错误。世博会应用程序只需返回第一页。
设备: 安卓 7
XDE:世博版本 2.21.00
应用.js
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
更新
npm 启动日志:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Users\Pfn\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'start' ]
2 info using npm@5.5.1
3 info using node@v6.11.3
4 verbose stack Error: missing script: start
4 verbose stack at run (C:UsersPfnAppDataRoamingnpmnode_modulesnpmlibrun-script.js:151:19)
4 verbose stack at C:UsersPfnAppDataRoamingnpmnode_modulesnpmlibrun-script.js:61:5
4 verbose stack at C:UsersPfnAppDataRoamingnpmnode_modulesnpmnode_modulesread-package-jsonread-json.js:115:5
4 verbose stack at C:UsersPfnAppDataRoamingnpmnode_modulesnpmnode_modulesread-package-jsonread-json.js:402:5
4 verbose stack at checkBinReferences_ (C:UsersPfnAppDataRoamingnpmnode_modulesnpmnode_modulesread-package-jsonread-json.js:357:45)
4 verbose stack at final (C:UsersPfnAppDataRoamingnpmnode_modulesnpmnode_modulesread-package-jsonread-json.js:400:3)
4 verbose stack at then (C:UsersPfnAppDataRoamingnpmnode_modulesnpmnode_modulesread-package-jsonread-json.js:160:5)
4 verbose stack at ReadFileContext.<anonymous> (C:UsersPfnAppDataRoamingnpmnode_modulesnpmnode_modulesread-package-jsonread-json.js:332:20)
4 verbose stack at ReadFileContext.callback (C:UsersPfnAppDataRoamingnpmnode_modulesnpmnode_modulesgraceful-fsgraceful-fs.js:78:16)
4 verbose stack at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:367:13)
5 verbose cwd F:reactmy-new-project
6 verbose Windows_NT 10.0.15063
7 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Users\Pfn\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "start"
8 verbose node v6.11.3
9 verbose npm v5.5.1
10 error missing script: start
11 verbose exit [ 1, true ]
添加此内容后:
"scripts": {
"start": "node app.js"
}
到package.json
日志:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Users\Pfn\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'start' ]
2 info using npm@5.5.1
3 info using node@v6.11.3
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle my-new-project@0.0.0~prestart: my-new-project@0.0.0
6 info lifecycle my-new-project@0.0.0~start: my-new-project@0.0.0
7 verbose lifecycle my-new-project@0.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle my-new-project@0.0.0~start: PATH: C:UsersPfnAppDataRoamingnpmnode_modulesnpmbinnode-gyp-bin;F:reactmy-new-projectnode_modules.bin;C:Program FilesExpo XDEresourcesappnode_modulesxdlbinarieswindowsadb;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:Program Files (x86)Smart ProjectsIsoBuster;C:Program FilesPuTTY;C:Program Files (x86)NVIDIA CorporationPhysXCommon;D:xamppphp;C:ProgramDataComposerSetupbin;C:Program Filesnodejs;C:UsersPfnAppDataRoamingnpm;C:UsersPfnAppDataLocalMicrosoftWindowsApps;C:UsersPfnAppDataRoamingComposervendorbin;C:UsersPfnAppDataRoamingnpm
9 verbose lifecycle my-new-project@0.0.0~start: CWD: F:reactmy-new-project
10 silly lifecycle my-new-project@0.0.0~start: Args: [ '/d /s /c', 'node app.js' ]
11 silly lifecycle my-new-project@0.0.0~start: Returned: code: 1 signal: null
12 info lifecycle my-new-project@0.0.0~start: Failed to exec start script
13 verbose stack Error: my-new-project@0.0.0 start: `node app.js`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:UsersPfnAppDataRoamingnpmnode_modulesnpmnode_modulesnpm-lifecycleindex.js:280:16)
13 verbose stack at emitTwo (events.js:106:13)
13 verbose stack at EventEmitter.emit (events.js:191:7)
13 verbose stack at ChildProcess.<anonymous> (C:UsersPfnAppDataRoamingnpmnode_modulesnpmnode_modulesnpm-lifecyclelibspawn.js:55:14)
13 verbose stack at emitTwo (events.js:106:13)
13 verbose stack at ChildProcess.emit (events.js:191:7)
13 verbose stack at maybeClose (internal/child_process.js:920:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:230:5)
14 verbose pkgid my-new-project@0.0.0
15 verbose cwd F:reactmy-new-project
16 verbose Windows_NT 10.0.15063
17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Users\Pfn\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "start"
18 verbose node v6.11.3
19 verbose npm v5.5.1
20 error code ELIFECYCLE
21 error errno 1
22 error my-new-project@0.0.0 start: `node app.js`
22 error Exit status 1
23 error Failed at the my-new-project@0.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
更新2:
npm 安装警告:
npm WARN react-native-branch@2.0.0-beta.3 requires a peer of react@>=15.4.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-gesture-handler@1.0.0-alpha.28 requires a peer of react@> 15.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: sshpk@1.13.0 (node_modulesfseventsnode_modulessshpk):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename 'F:reactmy-new-projectnode_modulesfseventsnode_modulessshpk' -> 'F:reactmy-new-projectnode_modulesfseventsnode_modules.sshpk.DELETE'
added 5 packages and updated 2 packages in 70.53s
哪个操作系统?Mac、Win还是Linux?如果您使用的是 Linux,您是否使用此命令打开了 XDE 客户端?
On Linux, open with chmod a+x xde*.AppImage and ./xde*.AppImage
无论您的操作系统如何,您确定您有...
- 安装了最新版本的节点?
- 安装了最新版本的守望者?
黑暗中的镜头,但是一旦您更新了上述内容,我会开始一个新项目并重试。
更新:更仔细地查看您的日志,我可以看到您在 Windows 上,因为路径是"C:\...",因此请忽略上面的 linux 注释。我仍然认为您的环境设置不正确。重新安装节点和/或守望者可能会有所帮助(很可能是节点)。您也可以尝试安装纱线,看看这是否有所作为。有时它对我有用。