我正在尝试在lerna包结构中创建一个新的react本机应用程序,但是我收到以下错误:
$ react-native init app
This will walk you through creating a new React Native project in /Volumes/DADOS/dev/workspace/amplifactory/packages/app
Using yarn v1.6.0
Installing react-native...
yarn add v1.6.0
(node:3689) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "workspace-aggregator-8ea62db7-5bb7-4a68-a0d4-fdec926563d9 > @monorepo/admin > babel-loader@7.1.4" has unmet peer dependency "babel-core@6".
warning "workspace-aggregator-8ea62db7-5bb7-4a68-a0d4-fdec926563d9 > @monorepo/admin > babel-preset-react-app@3.1.1" has unmet peer dependency "babel-runtime@^6.23.0".
warning "workspace-aggregator-8ea62db7-5bb7-4a68-a0d4-fdec926563d9 > @monorepo/admin > eslint-config-react-app@2.1.0" has incorrect peer dependency "babel-eslint@^7.2.3".
warning "workspace-aggregator-8ea62db7-5bb7-4a68-a0d4-fdec926563d9 > @monorepo/ux > react-datetime@2.14.0" has unmet peer dependency "moment@>=2.16.0".
warning "react-native > eslint-plugin-react-native@3.2.1" has unmet peer dependency "eslint@^3.17.0 || ^4.0.0".
warning " > react-native@0.55.4" has unmet peer dependency "react@16.3.1".
[4/4] Building fresh packages...
success Saved 7 new dependencies.
info Direct dependencies
info All dependencies
├─ @monorepo/admin@3.0.0
├─ @monorepo/auth@3.0.0
├─ @monorepo/boffice@3.0.0
├─ @monorepo/graphqlserver@3.0.0
├─ @monorepo/studio@3.0.0
├─ app@0.0.1
└─ react-native@0.55.4
✨ Done in 8.38s.
internal/modules/cjs/loader.js:596
throw err;
^
Error: Cannot find module '/Volumes/dev/workspace/amplifactory/packages/app/node_modules/react-native/package.json'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at checkNodeVersion (/usr/local/lib/node_modules/react-native-cli/index.js:306:21)
at run (/usr/local/lib/node_modules/react-native-cli/index.js:300:3)
at createProject (/usr/local/lib/node_modules/react-native-cli/index.js:249:3)
at init (/usr/local/lib/node_modules/react-native-cli/index.js:200:5)
at Object.<anonymous> (/usr/local/lib/node_modules/react-native-cli/index.js:153:7)
at Module._compile (internal/modules/cjs/loader.js:702:30)
环境:
由于我无法在我的lerna包中创建它,我已经在lerna外创建了app包,然后转移到lerna packages文件夹并更改了package.json
文件:
{
"name": "@monorepo/app",
"version": "3.0.0",
"private": true,
"scripts": {
"start-dev": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.4"
},
"devDependencies": {
"babel-jest": "23.0.1",
"babel-preset-react-native": "4.0.0",
"jest": "23.1.0",
"react-test-renderer": "16.3.1"
},
"jest": {
"preset": "react-native"
}
}
在查找文件后,我使用lerna重新安装它:
$ yarn install
尝试运行应用时,我收到以下错误:
我的lerna配置文件:
{
"lerna": "2.9.0",
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [
"packages/*"
],
"version": "3.0.0"
}
如何正确地将反应原生包添加到lerna并使其正常运行?