几天来,我一直在为我的本机安装而苦苦挣扎。我正在按照Getting Started指南进行操作,选择了适用于Android的Linux开发。
首先,我成功安装了nodejs
:
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
然后我成功安装了react-native
:
npm install -g react-native-cli
但是当我使用react-native init InitTest
初始化项目时,会收到大量警告:
This will walk you through creating a new React Native project in /home/markus/Documents/Programming/LukasApp/InitTest
Using yarn v1.15.2
Installing react-native...
yarn add v1.15.2
warning ../../../../package.json: No license field
info No lockfile found.
[1/4] Resolving packages...
warning react-native > create-react-class > fbjs > core-js@1.2.7: core-js@<2.6.5 is no longer maintained. Please, upgrade to core-js@3 or at least to actual version of core-js@2.
[2/4] Fetching packages...
info fsevents@1.2.9: The platform "linux" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "react-native > metro-react-native-babel-transformer@0.51.0" has unmet peer dependency "@babel/core@*".
warning "react-native > @react-native-community/cli > metro-react-native-babel-transformer@0.51.1" has unmet peer dependency "@babel/core@*".
warning " > react-native@0.59.5" has unmet peer dependency "react@16.8.3".
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 351 new dependencies.
info Direct dependencies
└─ react-native@0.59.5
info All dependencies
├─ @babel/helper-builder-binary-assignment-operator-visitor@7.1.0
├─ @babel/helper-builder-react-jsx@7.3.0
........
├─ y18n@3.2.1
└─ yargs-parser@7.0.0
Done in 3.83s.
info Setting up new React Native app in /home/markus/Documents/Programming/LukasApp/InitTest
info Adding required dependencies
yarn add v1.15.2
warning ../../../../package.json: No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.9: The platform "linux" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "react-native > metro-react-native-babel-transformer@0.51.0" has unmet peer dependency "@babel/core@*".
warning "react-native > @react-native-community/cli > metro-react-native-babel-transformer@0.51.1" has unmet peer dependency "@babel/core@*".
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 2 new dependencies.
info Direct dependencies
└─ react@16.8.3
info All dependencies
├─ react@16.8.3
└─ scheduler@0.13.6
Done in 1.41s.
info Adding required dev dependencies
yarn add v1.15.2
warning ../../../../package.json: No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
warning Pattern ["@babel/core@^7.4.4"] is trying to unpack in the same destination "/home/markus/.cache/yarn/v4/npm-@babel-core-7.4.4-84055750b05fcd50f9915a826b44fa347a825250/node_modules/@babel/core" as pattern ["@babel/core@^7.0.0","@babel/core@^7.0.0","@babel/core@^7.0.0","@babel/core@^7.0.0","@babel/core@^7.0.0","@babel/core@^7.0.0","@babel/core@^7.0.0","@babel/core@^7.1.0","@babel/core@^7.1.0"]. This could result in non-deterministic behavior, skipping.
warning Pattern ["@babel/runtime@^7.4.4"] is trying to unpack in the same destination "/home/markus/.cache/yarn/v4/npm-@babel-runtime-7.4.4-dc2e34982eb236803aa27a07fea6857af1b9171d/node_modules/@babel/runtime" as pattern ["@babel/runtime@^7.0.0"]. This could result in non-deterministic behavior, skipping.
info fsevents@1.2.9: The platform "linux" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 144 new dependencies.
info Direct dependencies
├─ @babel/runtime@7.4.4
├─ babel-jest@24.7.1
├─ jest@24.7.1
├─ metro-react-native-babel-preset@0.53.1
└─ react-test-renderer@16.8.3
info All dependencies
├─ @babel/runtime@7.4.4
├─ @cnakazawa/watch@1.0.3
......
├─ y18n@4.0.0
└─ yargs-parser@11.1.1
Done in 3.41s.
我尝试搜索选定的警告,但是对于每个修复程序,我只会收到更多警告,甚至是错误消息。
我可以在模拟器上运行该应用程序,因此没有错误。所以我想到了不理会警告。但是,例如,如果我尝试将firebase
与npm install firebase --save
一起安装,则会再次收到很多警告,然后是一个错误,这是(我想)与此问题有关。
如果有人有任何有用的评论,我将非常感谢!
编辑:应该注意的是,我在安装过程中更改了npm的默认全局安装路径。我将其设置为/home/markus/.npm-global/