Skip to content
This repository has been archived by the owner on May 3, 2023. It is now read-only.

Add support for Windows #10

Closed
aclement455 opened this issue Jun 19, 2019 · 18 comments
Closed

Add support for Windows #10

aclement455 opened this issue Jun 19, 2019 · 18 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@aclement455
Copy link

This is a great tool, it would be good if windows were also supported, right now I am getting the following error:

npx jetify
The system cannot find the path specified.

Thanks!

@aclement455
Copy link
Author

FWIW, I also tried it on WSL without success:

root@DESKTOP-6NA1MB4:/mnt/c/Users/aclement/Documents/rn-project/rn# npx jetify
: not founds/aclement/AppData/Roaming/nvm/v10.15.1/npx: 3: /mnt/c/Users/aclement/AppData/Roaming/nvm/v10.15.1/npx:
: not founds/aclement/AppData/Roaming/nvm/v10.15.1/npx: 5: /mnt/c/Users/aclement/AppData/Roaming/nvm/v10.15.1/npx:
/mnt/c/Users/aclement/AppData/Roaming/nvm/v10.15.1/npx: 6: /mnt/c/Users/aclement/AppData/Roaming/nvm/v10.15.1/npx: Syntax error: word unexpected (expecting "in")

@mikehardy
Copy link
Owner

thank you for trying! We'll see what we can do. I wonder if it is a shell difference, like bash isn't behaving the same? It might be trivial to fix as it seems to just be a for loop failure?

@mikehardy mikehardy added bug Something isn't working help wanted Extra attention is needed labels Jun 19, 2019
@mikehardy
Copy link
Owner

I will mention that I do not have a Windows development rig, so anyone that can help with this I will grant one virtual 🍺 and 20 internet points ;-)

@aclement455
Copy link
Author

Alright, so turns out I just didn't know how to use the WSL correctly. Just needed, update, upgrade and re-install npm. But now I am getting a different message.

npx jetify
...
jetifying file node_modules/react-native/local-cli/templates/HelloWorld/android/app/src/main/res/values/styles.xml
sed: couldn't open file node_modules/jetifier/src/androidx-class-mapping.sed: No such file or directory
...

Am I missing a step here?

@mikehardy
Copy link
Owner

🤔 hmm @laurent22 reported windows success so there must be something going on. It's possible though apparently, just maybe touchy. Hopefully we can document it well shortly (and fix if needed, of course)

@aclement455
Copy link
Author

Oh I added jetifier globally, the mapping is only pointing to node_modules. Seems to work when I add it locally, 👍

@mikehardy
Copy link
Owner

That's an important clue! I mention you can add it globally if you want but if that doesn't work I need to update the README, thank you for keeping after it to find out. Glad it's working!

@pavelustenko
Copy link

Still can't get it work on windows 10.
I've installed jetifier using "yarn add jetifier --dev"
npx without any params work as expected, but "npx jetify" doesn't do any job, but displays "The system cannot find the path specified." message. Is there any workaround?

@laurent22
Copy link
Collaborator

laurent22 commented Jun 20, 2019

@pavelustenko, from WSL, did you try to specify the jetify path directly? eg. ./node_modules/.bin/jetify? I forgot the exact path, but basically run the binary in node_modules directly.

@pavelustenko
Copy link

pavelustenko commented Jun 20, 2019

@pavelustenko, from WSL, did you try to specify the jetify path directly? eg. ./node_modules/.bin/jetify? I forgot the exact path, but basically run the binary in node_modules directly.

Yes, just tried. But same result.

@laurent22
Copy link
Collaborator

I've just tried like this:

  • From Windows command (not WSL):

    npm i -s jetifier

  • From WSL:

    npx jetify

And that worked for me, it started processing the java files. What happens if you try this?

@pavelustenko
Copy link

I've just realized that jetify script needs bash to run...

@pavelustenko
Copy link

And that worked for me, it started processing the java files. What happens if you try this?

The system cannot find the path specified

@mikehardy
Copy link
Owner

I can add to the README that we need bash, and that you should try the path directly for windows (./node_modules/.bin/jetify) - you also need find and sed, maybe those are missing?

@pavelustenko
Copy link

Sorry for nubbie question, I couldn't get that thing work on Win10. My task was to build a RN project that suddenly refused to build causelessly. I solved it using "refactor->migrate to androidx" in Android Studio. Does this program does the same?

@mikehardy
Copy link
Owner

@pavelustenko https://github.com/mikehardy/jetifier/blob/master/README.md#L19

this converts source in node_modules in addition to normal android studio jetifier

@normanzhao
Copy link

I'm not really sure where to put this, but for those with Windows but still can't use this tool, I ported it over to Python. It's here and written in Python 2.7. You'll need the glob2 package to run it as well. To run, copy both files to your project directory and type in python jetifier.py, you can optionally set -r for it to run in reverse. It's also pretty fast.

@mikehardy
Copy link
Owner

If you want to make a PR that installs this as a different method and installs it as jetifier.py or similar, that'd be fine - just make sure it passes rn-androidx-demo as a test suite first :-) - but you might like jetifire (note slightly different spelling, linked on the performance issue here) which is pure javascript.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants