Closed shirakaba closed 2 months ago
As react-native-windows-init
will be marked as deprecated in 0.75, you can use the new init-windows
command which allows you to specify whatever name
and/or namespace
you want for the native code, rather than strictly relying the value in package.json
. There's a lot of tangled up history in what names do/don't work in the old command (as the one string is frankly overused in the templates, for more than just file names) and the rules for that string have also changed over the years.
Anyway, while technically we're "launching" this new command in 0.75, I believe it's already in a working state in 0.73. If you've already added react-native-windows
to your project, try using npx react-native init-windows
with any of the available "old/" templates, the list of which you can see via a preview the upcoming docs here: https://microsoft.github.io/react-native-windows/docs/next/init-windows-cli.
Caution: The new architecture templates available from this command are in no way ready or supported, especially in whatever state they were in in RNW 0.73.
@jonthysell Thank you! Could you point me at the code for the init-windows
CLI and the locations of the templates that it references? I've been struggling to find details about it.
EDIT: I guess the templates for init-windows
are in react-native-windows/vnext/templates, though I'm not clear where the code for the init-windows
CLI is.
Problem Description
react-native-windows-init
fails when run inside a project whose name (i.e. the "name" field in itspackage.json
) is prefixed by an org. So, while a project name ofreact-native-app-auth-js
is fine,@my-org/react-native-app-auth-js
is not:The reason for failure is that, although it generates a directory named
react-native-app-auth-js
to write boilerplate into, it neglects to generate the parent directory@my-org
.Steps To Reproduce
package.json
, I set"name": "@my-org/react-native-app-auth-js"
.Then, I ran this command, and it failed:
I found that if I renamed the package from
@my-org/react-native-app-auth-js
toreact-native-app-auth-js
, the command ran fine.Expected Results
The CLI should support org prefixes in package names.
CLI version
npx @react-native-community/cli -v
Environment
Community Modules
None
Target Platform Version
None
Target Device(s)
No response
Visual Studio Version
Visual Studio 2022
Build Configuration
None
Snack, code example, screenshot, or link to a repository
No response