简体   繁体   English

react-native node 依赖安装破坏了项目

[英]react-native node dependency install broke project

I am trying to develop my first android app using react-native and expo for testing, on windows 8.1.我正在尝试在 Windows 8.1 上使用react-nativeexpo开发我的第一个 android 应用程序进行测试。

Working from a tutorial I had a working project using react-native components but everything broke when I installed a dependency with从教程开始,我有一个使用react-native组件的工作项目,但是当我安装依赖项时,一切都坏了

`npm install --save react-navigation`:  

npm-start returned npm-start返回

Error: React native is not installed.错误:未安装 React Native。 Please run 'npm install' in your project directory.请在您的项目目录中运行“npm install”。

So I ran npm-install again as suggested.所以我按照建议再次运行npm-install
This led to npm-start asking me if I want to install expo-cli globally, and whether I answer yes or no I get the following error:这导致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

The log mentioned in this message is as follows:该消息中提到的日志如下:

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 ]

I searched on StackOverflow and followed the advice to deal with ELIFECYCLE errors found in this answer .我在 StackOverflow 上搜索并按照建议处理此答案中发现的ELIFECYCLE错误。 runnning npm cache clean then deleting the node_modules directory and package-lock.json buit the error is the same. npm cache clean然后删除node_modules目录和package-lock.json但错误是一样的。
I even tried doing these steps as well as removing the react-navigation from my dependencies in my package.json file and in my code before running npm-install again, but it didn't change anything.我什至尝试执行这些步骤,并在再次运行npm-install之前从我的package.json文件和代码中的依赖项中删除react-navigation ,但它没有改变任何内容。

It is interesting to note that when running expo start on it's own it manages to launch the bundler and the devtools in the browser just not with the right ip address.有趣的是,当它自己运行expo start时,它设法在浏览器中启动捆绑器和 devtools,只是没有使用正确的 IP 地址。

I also don't know if this is important but when running npm-install I get 2 vulnerabilities, when I run npm-audit it indicates that the is a low 'Prototype Pollution' vulnerability in the lodash package and a High 'Denial of Service' vulnerability in the ws package.我也不知道这是否重要,但是在运行npm-install我得到了 2 个漏洞,当我运行npm-audit它表明 lodash 包中的“原型污染”漏洞低,而“拒绝服务”漏洞高' ws 包中的漏洞。 But nothing changes even after running npm audit fix但是即使在运行npm audit fix之后也没有任何变化

Anyway I hope you can help me, thanks!无论如何,我希望你能帮助我,谢谢!

I was having the same problem.我遇到了同样的问题。

If you run:如果你运行:

npm i expo-cli

and then进而

npm start

It will work它会工作

就我而言,未安装 angular-cli,因此我将命令运行为 -

npm install -g angular-cli

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM