我通过使用“ npm install --save react-native-elements”安装来向我的项目中添加react native元素,但是它破坏了我的项目。我找不到正确的解决方案。我不知道该如何解决。
安装React本机元素后,
我收到一个错误“错误:未安装 React Native。请在您的项目目录中运行npm install
。
[21:03:06]无法启动项目。请更正错误,然后重新启动项目。
[21:03:06]在环境中设置EXPO_DEBUG = true以查看堆栈跟踪。”
这是我第一次发布关于stackoverflow的问题。如果我犯了任何错误,对此我感到抱歉。
C:\>cd react native project
C:\react native project>expo init just1
? Choose a template: expo-template-blank
? Yarn v1.12.3 found. Use Yarn to install dependencies? Yes
[20:49:42] Extracting project files...
[20:49:45] Customizing project...
[20:49:45] Installing dependencies...
yarn install v1.12.3
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.4: The platform "win32" is incompatible with this module.
info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "expo > expo-background-fetch@1.0.0" has unmet peer dependency "expo-task-manager-interface@~1.0.0".
warning "expo > expo-google-sign-in@2.0.0" has incorrect peer dependency "react-native@^0.55.4".
warning "expo > expo-location@2.0.0" has unmet peer dependency "expo-task-manager-interface@~1.0.0".
warning "expo > react-native-reanimated@1.0.0-alpha.11" has incorrect peer dependency "react@16.0.0-alpha.6".
warning "expo > react-native-reanimated@1.0.0-alpha.11" has incorrect peer dependency "react-native@^0.44.1".
warning "expo > expo-asset > url-loader@1.1.2" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset@0.49.2" has unmet peer dependency "@babel/core@*".
warning "expo > babel-preset-expo > @babel/plugin-proposal-decorators@7.2.3" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-syntax-export-default-from@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-syntax-dynamic-import@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-proposal-export-default-from@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-computed-properties@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-classes@7.2.2" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-for-of@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-arrow-functions@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-destructuring@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-function-name@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-exponentiation-operator@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-block-scoping@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-react-display-name@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-react-jsx@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-parameters@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-literals@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-object-assign@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-regenerator@7.0.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-runtime@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-sticky-regex@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-shorthand-properties@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-spread@7.2.2" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-react-jsx-source@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-template-literals@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-typescript@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-unicode-regex@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > @babel/plugin-proposal-decorators > @babel/helper-create-class-features-plugin@7.2.3" has unmet peer dependency "@babel/core@^7.0.0".
warning "expo > babel-preset-expo > @babel/plugin-proposal-decorators > @babel/plugin-syntax-decorators@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-proposal-optional-catch-binding > @babel/plugin-syntax-optional-catch-binding@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-proposal-object-rest-spread > @babel/plugin-syntax-object-rest-spread@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-proposal-optional-chaining > @babel/plugin-syntax-optional-chaining@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-proposal-nullish-coalescing-operator > @babel/plugin-syntax-nullish-coalescing-operator@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-react-jsx > @babel/plugin-syntax-jsx@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-flow-strip-types > @babel/plugin-syntax-flow@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "expo > babel-preset-expo > metro-react-native-babel-preset > @babel/plugin-transform-typescript > @babel/plugin-syntax-typescript@7.2.0" has unmet peer dependency "@babel/core@^7.0.0-0".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 151.57s.
Your project is ready at C:\react native project\just1
To get started, you can type:
cd just1
yarn start
C:\react native project>cd just1
C:\react native project\just1>npm install --save react-native-elements
npm WARN rm not removing C:\react native project\just1\node_modules\.bin\uuid.cmd as it wasn't installed by C:\react native project\just1\node_modules\uuid
npm WARN rm not removing C:\react native project\just1\node_modules\.bin\uuid as it wasn't installed by C:\react native project\just1\node_modules\uuid
npm WARN rm not removing C:\react native project\just1\node_modules\.bin\json5.cmd as it wasn't installed by C:\react native project\just1\node_modules\json5
npm WARN rm not removing C:\react native project\just1\node_modules\.bin\json5 as it wasn't installed by C:\react native project\just1\node_modules\json5
npm WARN rm not removing C:\react native project\just1\node_modules\.bin\jsesc.cmd as it wasn't installed by C:\react native project\just1\node_modules\jsesc
npm WARN rm not removing C:\react native project\just1\node_modules\.bin\jsesc as it wasn't installed by C:\react native project\just1\node_modules\jsesc
> react-native-elements@0.19.1 postinstall C:\react native project\just1\node_modules\react-native-elements
> opencollective postinstall
*** Thank you for using react-native-elements! ***
Please consider donating to our open collective
to help us maintain this package.
https://opencollective.com/react-native-elements/donate
***
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN react-native-maps@0.22.1 requires a peer of react-native@>= 0.51 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-elements@0.19.1 requires a peer of react-native-vector-icons@^4.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN expo-google-sign-in@2.0.0 requires a peer of react-native@^0.55.4 but none is installed. You must install peer dependencies yourself.
npm WARN expo-react-native-adapter@2.0.0 requires a peer of react-native@^0.57.1 but none is installed. You must install peer dependencies yourself.
npm WARN lottie-react-native@2.5.0 requires a peer of react-native@>=0.46 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-branch@2.2.5 requires a peer of react-native@>=0.40.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-gesture-handler@1.0.12 requires a peer of react-native@>= 0.50.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-reanimated@1.0.0-alpha.11 requires a peer of react@16.0.0-alpha.6 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-reanimated@1.0.0-alpha.11 requires a peer of react-native@^0.44.1 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-screens@1.0.0-alpha.19 requires a peer of react-native@* but none is installed. You must install peer dependencies yourself.
npm WARN react-native-view-shot@2.5.0 requires a peer of react-native@* but none is installed. You must install peer dependencies yourself.
npm WARN react-native-svg@8.0.10 requires a peer of react-native@>=0.50.0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-proposal-decorators@7.2.3 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN metro-react-native-babel-preset@0.49.2 requires a peer of @babel/core@* but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-syntax-decorators@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/helper-create-class-features-plugin@7.2.3 requires a peer of @babel/core@^7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-proposal-object-rest-spread@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-proposal-nullish-coalescing-operator@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-proposal-export-default-from@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-proposal-class-properties@7.2.3 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-proposal-optional-chaining@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-proposal-optional-catch-binding@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-syntax-dynamic-import@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-arrow-functions@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-syntax-export-default-from@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-block-scoping@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-classes@7.2.2 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-computed-properties@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-destructuring@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-exponentiation-operator@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-for-of@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-flow-strip-types@7.2.3 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-function-name@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-literals@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-modules-commonjs@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-object-assign@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-react-jsx@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-parameters@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-react-jsx-source@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-react-display-name@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-runtime@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-shorthand-properties@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-regenerator@7.0.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-spread@7.2.2 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-sticky-regex@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-template-literals@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-unicode-regex@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-typescript@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-syntax-nullish-coalescing-operator@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-syntax-object-rest-spread@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-syntax-optional-catch-binding@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-syntax-optional-chaining@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-syntax-flow@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-syntax-jsx@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-syntax-typescript@7.2.0 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN url-loader@1.1.2 requires a peer of webpack@^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-safe-module@1.2.0 requires a peer of react-native@* but none is installed. You must install peer dependencies yourself.
+ react-native-elements@0.19.1
added 17 packages from 15 contributors, removed 412 packages and updated 342 packages in 389.605s
C:\react native project\just1>expo start
[21:02:38] Starting project at C:\react native project\just1
[21:02:45] Expo DevTools is running at http://localhost:19003
[21:02:45] Opening DevTools in the browser... (press shift-d to disable)
[21:03:06] Error: React Native is not installed. Please run `npm install` in your project directory.
[21:03:06] Couldn't start project. Please fix the errors and restart the project.
[21:03:06] Set EXPO_DEBUG=true in your env to view the stack trace.
C:\react native project\just1>
My project should have worked fine but it actually started giving me bad errors
答案 0 :(得分:1)
最初设置博览会时,它使用的是纱线。如果您使用npm安装软件包,则由于没有package-lock.json
您可以通过运行npm i
来解决此问题,它应该重新安装已删除的依赖项。
您应该使用yarn
或npm
而不是两者结合使用,否则可能会导致问题。
答案 1 :(得分:0)
我遇到了同样的问题,正在运行“ npm审核修复程序” 为我固定。希望对您有帮助