我正在尝试使用react-native和expo在Windows 8.1上开发我的第一个Android应用程序进行测试。
从一个教程开始,我有一个使用react-native组件的工作项目,但是当我使用
安装依赖项时,一切都崩溃了`npm install --save react-navigation`:
npm-start
返回了
错误:未安装React native。请在您的项目目录中运行“ npm install”。
所以我按照建议再次运行了npm-install
。
这导致npm-start
询问我是否要全局安装expo-cli,是否回答是或否,但出现以下错误:
Installing the package [expo-cli][1]...
events.js:167
throw er; // Unhandled 'error' event
^
Error: spawn npm ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:232:19)
at onErrorNT (internal/child_process.js:407:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:238:12)
at onErrorNT (internal/child_process.js:407:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! empty-project-template@ start: `expo start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the empty-project-template@ 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! C:\Users\me\AppData\Roaming\npm-cache\_logs\2018-09-25T21_27_21_053Z-debug.log
此消息中提到的日志如下:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'start' ]
2 info using npm@6.4.1
3 info using node@v10.11.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle empty-project-template@~prestart: empty-project-template@
6 info lifecycle empty-project-template@~start: empty-project-template@
7 verbose lifecycle empty-project-template@~start: unsafe-perm in lifecycle true
8 verbose lifecycle empty-project-template@~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\androidProjects\MoviesAndMe\node_modules\.bin;C:\Python27\;C:\Python27\Scripts;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\libnvvp;C:\ProgramData\Anaconda3;C:\ProgramData\Anaconda3\Library\mingw-w64\bin;C:\ProgramData\Anaconda3\Library\usr\bin;C:\ProgramData\Anaconda3\Library\bin;C:\ProgramData\Anaconda3\Scripts;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Java\jre7\bin;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\Skype\Phone\;C:\Android;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\ProgramData\chocolatey\bin;C:\Program Files\nodejs\;C:\Users\me\Documents\Latex\miktex\bin\;C:\Users\me\AppData\Local\atom\bin;C:\Users\me\AppData\Local\hyper\app-2.0.0\resources\bin;C:\Program Files\Java\jdk1.8.0_181\bin;C:\Users\me\AppData\Roaming\npm
9 verbose lifecycle empty-project-template@~start: CWD: D:\androidProjects\MoviesAndMe
10 silly lifecycle empty-project-template@~start: Args: [ '/d /s /c', 'expo start' ]
11 silly lifecycle empty-project-template@~start: Returned: code: 1 signal: null
12 info lifecycle empty-project-template@~start: Failed to exec start script
13 verbose stack Error: empty-project-template@ start: `expo start`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:182:13)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:182:13)
13 verbose stack at maybeClose (internal/child_process.js:962:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
14 verbose pkgid empty-project-template@
15 verbose cwd D:\androidProjects\MoviesAndMe
16 verbose Windows_NT 6.3.9600
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v10.11.0
19 verbose npm v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error empty-project-template@ start: `expo start`
22 error Exit status 1
23 error Failed at the empty-project-template@ start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
我搜索了StackOverflow,并按照建议处理了this answer中发现的ELIFECYCLE
个错误。运行npm cache clean
,然后删除node_modules
目录和package-lock.json
,但错误是相同的。
我什至尝试执行这些步骤,以及在再次运行react-navigation
之前从我的package.json
文件和代码中的依赖项中删除npm-install
,但是它没有任何改变。>
有趣的是,在单独运行expo start
时,它设法在浏览器中启动捆绑程序和devtools只是没有正确的IP地址。
我也不知道这是否重要,但是在运行npm-install
时我有2个漏洞,当我运行npm-audit
时表明lodash软件包中的'Prototype Pollution'漏洞很低ws软件包中的“拒绝服务”漏洞很高。但是即使运行npm audit fix
无论如何,希望您能帮助我,谢谢!
答案 0 :(得分:2)
我遇到了同样的问题。
如果您运行:
npm i expo-cli
然后
npm start
它将起作用
答案 1 :(得分:0)
在我的情况下,未安装angular-cli,因此我以-
的身份运行命令npm install -g angular-cli