Comments (9)
Adding this default react-native.config.js to packageB
root also resolved the issue.
from cli.
PS, I found @react-native/community-cli-plugin, which seems to carry the bundle
command and is marked as "Formerly @react-native-community/cli-plugin-metro".
But the usage leads me back to my original issue:
npx react-native bundle --entry-file <path> [options]
from cli.
hey @davidseek! that's strange these commands should be added by Core thanks to @react-native/community-cli-plugin
, please make sure that you have proper react-native
version, and also do you mind running npx react-native config
?
from cli.
Thanks for getting back to me. The problem seems to be the following:
My workspace has 2 npm packages.
- Package A contains all node_modules, aka 3p dependencies
- Package B is my Manifest, it syncs the node_modules from Package A
Running bundle command from Package A works.
Package A -> node node_modules/react-native/local-cli/cli.js bundle
Welcome to Metro v0.80.4
Fast - Scalable - Integrated
Running bundle command from Package B does not work.
Package B -> node node_modules/react-native/local-cli/cli.js bundle
error: unknown command 'bundle'
Even when I try to call the script from Package A from within Package B it also throws the same issue.
Package B -> node ../Package A/node_modules/react-native/local-cli/cli.js bundle
error: unknown command 'bundle'
Only works if I call it directly from the root of Package A.
Package A -> node node_modules/react-native/local-cli/cli.js bundle
Welcome to Metro v0.80.4
Fast - Scalable - Integrated
node_modules
of both packages are in sync. I understand that you're not exactly supporting custom setups, but any clue why Package A can find the bundle
info from within @react-native
, as you described, but Package B can't?
from cli.
- Does running commands via
npx react-native
change something? - Could you please confirm if the config return from
npx react-native config
command from package A is the same as from package B? If not, what's the difference?
from cli.
npx react-native
works in Package A, just like callingcli.js bundle
directlynpx react-native
in Package B leads tounknown command 'bundle'
Package B npx react-native config
output:
{
"root": "/Volumes/workplace/Package B",
"reactNativePath": "/Volumes/workplace/Package B/node_modules/react-native",
"reactNativeVersion": "0.73",
"dependencies": {},
"commands": [],
"healthChecks": [],
"platforms": {},
"project": {}
}
Package A npx react-native config
output shows a WHOLE LOT MORE, and also contains the bundle command.
"root": "/Volumes/workplace/Package A",
"reactNativePath": "/Volumes/workplace/Package A/node_modules/react-native",
"reactNativeVersion": "0.73",
....
"commands": [
{ "name": "bundle",
"description": "Build the bundle for the provided JavaScript entry file.",
"options": [
{
"name": "--entry-file <path>",
"description": "Path to the root JS file, either absolute or relative to JS root"
},
{
...
"healthChecks": [],
"platforms": {
"ios": {},
"android": {}
},
"project": {
"ios": null,
"android": null
}
How can I sync this info from Package A to Package B?
from cli.
I have the same issue :error: unknown command 'bundle'
. I am also on the process of upgrading from 0.69 to 0.73. After debugging @react-native-community/cli
and @react-native-community/cli-config
libraries, It looks like your metro.config.js file should be under same level of node_modules/@react-native-community/cli**
folders
Have the following monorepo folder structure:
apps/
- mobile/
-- metro.config.js
-- react-native.js
node_modules/
- @react-native-community/
-- cli/
-- cli-config/
Eventually,I had to create symlinks to the config files folder in order to resolve the issue.
ln -snf node_modules/@react-native-community apps/mobile/node_modules
ln -snf node_modules/react-native apps/mobile/node_modules
Obviously, this cannot be a desired solution. Hopefully, we can find a better solution. It is an annoying issue indeed.
from cli.
We have the following structure
packageA/
- node_nodules (original)
packageB/
- node_nodules (symlink of packageA/node_nodules)
- script for bundle creation
- metro config etc
We used to call the script for bundle creation
from packageB root. This throws now unknown command 'bundle'
. I'm able to call the same underlying command, equivalent to npx react-native bundle ...
from packageA and it works. But all my Configs and sources are in packageB. Metro config missing etc.
Symlinking the node_nodules
content as you did above @SemihGk wouldn't solve my issue. Because we're already doing that. I need to be able to call npx react-native bundle ...
from packageB.
from cli.
I found a way to bypass my issue. The key is, that packageB
has no direct dependencies. packageA
is the 3p dependencies repo which other packages symlink from.
In order to use the bundle
command, we had to add react-native
as a dependency within packageB
.
Without running yarn install
or npm install
, npx react-native bundle
works now as expected.
For us the key is not to actually have direct dependencies outside of packageA
.
Therefore I'm using a small script to add the dependency right before we build the bundle
.
// Pseudo
const json = await fs.readFile('package.json)
json.dependencies = { "react-native": "^0.73.2" }
await fs.writeFile('package.json, json)
from cli.
Related Issues (20)
- 🚨 Security Vulnerability: ip npm package is unsafe for use as of v1.1.8 HOT 21
- Could not create an empty Git repository, see debug logs with --verbose HOT 14
- Unable to start server in new window when using yarn with pnpm linker HOT 2
- FAILURE: Build failed with an exception.
- FAILURE: Build failed with an exception. Script '/home/xyz/Documents/CQ/projectName/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 375 HOT 1
- Implement support for Android activity aliases
- Not possible to specify macCatalyst UDID as run target
- Passing registry for different package managers HOT 5
- Health Check Plugin isn't executed when running `react-native doctor` HOT 2
- react-native run-android: Failed to install the app on the device. Error: Could not find the correct install APK file.
- How to build android release but with JS dev flag enabled?
- On Android, app isn't opened automatically if applicationId is changed HOT 1
- API not working in React native android but working in ios. HOT 1
- Can CRNA change name inside project like NPX react-native init? HOT 1
- ✖ Could not create an empty Git repository, see debug logs with --verbose HOT 2
- Execution failed for task ':app:buildCMakeDebug[x86]' HOT 4
- Stuck at info JS server already running on Linux 22.04 HOT 1
- Proposal: @react-native-community/template versioning scheme HOT 5
- Unsupported class file major version 66 error. HOT 5
- Error type 3 Error: Activity class {....} does not exist HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cli.